本文整理汇总了PHP中classXML::fetchElementsFromRecord方法的典型用法代码示例。如果您正苦于以下问题:PHP classXML::fetchElementsFromRecord方法的具体用法?PHP classXML::fetchElementsFromRecord怎么用?PHP classXML::fetchElementsFromRecord使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classXML
的用法示例。
在下文中一共展示了classXML::fetchElementsFromRecord方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _importTemplates
/**
* Run SQL files
*
* @access public
* @param int
*/
public function _importTemplates()
{
$templates = array();
$this->DB->build(array('select' => '*', 'from' => 'ccs_template_blocks'));
$outer = $this->DB->execute();
while ($r = $this->DB->fetch($outer)) {
if (!preg_match("/_(\\d+)\$/", $r['tpb_name'])) {
$templates[$r['tpb_name']] = $r;
}
}
$content = file_get_contents(IPSLib::getAppDir('ccs') . '/xml/block_templates.xml');
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
foreach ($xml->fetchElements('template') as $template) {
$_template = $xml->fetchElementsFromRecord($template);
if ($_template['tpb_name']) {
unset($_template['tpb_id']);
if (array_key_exists($_template['tpb_name'], $templates)) {
$this->DB->update("ccs_template_blocks", $_template, "tpb_id={$templates[$_template['tpb_name']]['tpb_id']}");
} else {
$this->DB->insert("ccs_template_blocks", $_template);
}
}
}
}
示例2: _importSite
/**
* Now we get to import the default site. Fun!
*
* @access protected
* @return void
*/
protected function _importSite()
{
$content = file_get_contents(IPS_ROOT_PATH . 'applications_addon/ips/ccs/xml/demosite.xml');
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
foreach ($xml->fetchElements('block') as $block) {
$_block = $xml->fetchElementsFromRecord($block);
$this->DB->insert("ccs_blocks", $_block);
}
foreach ($xml->fetchElements('container') as $container) {
$_container = $xml->fetchElementsFromRecord($container);
$this->DB->insert("ccs_containers", $_container);
}
foreach ($xml->fetchElements('folder') as $folder) {
$_folder = $xml->fetchElementsFromRecord($folder);
$this->DB->insert("ccs_folders", $_folder);
}
foreach ($xml->fetchElements('template') as $template) {
$_template = $xml->fetchElementsFromRecord($template);
$this->DB->insert("ccs_page_templates", $_template);
}
foreach ($xml->fetchElements('page') as $page) {
$_page = $xml->fetchElementsFromRecord($page);
$this->DB->insert("ccs_pages", $_page);
}
foreach ($xml->fetchElements('tblock') as $tblock) {
$_tblock = $xml->fetchElementsFromRecord($tblock);
$this->DB->insert("ccs_template_blocks", $_tblock);
}
foreach ($xml->fetchElements('cache') as $cache) {
$_cache = $xml->fetchElementsFromRecord($cache);
$this->DB->insert("ccs_template_cache", $_cache);
}
}
示例3: _restoreXmlSkin
/**
* Execute selected method
*
* @param object Registry object
* @return @e void
*/
public function _restoreXmlSkin()
{
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPSSetUp::charSet);
/* Skin Set Data */
$xml->load(IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml');
foreach ($xml->fetchElements('set') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
if ($data['set_key'] == 'xmlskin') {
$data['set_order'] = intval($data['set_order']);
unset($data['set_id']);
$this->DB->delete('skin_collections', "set_key='xmlskin'");
$this->DB->insert('skin_collections', $data);
}
}
$this->registry->output->addMessage("XML стиль восстановлен");
$this->request['workact'] = '';
}
示例4: finish
/**
* Finish up conversion stuff
*
* @return @e void
*/
public function finish()
{
$options = IPSSetUp::getSavedData('custom_options');
$skipPms = $options['core'][30001]['skipPms'];
$output = array();
/* Emoticons */
if (file_exists(DOC_IPS_ROOT_PATH . 'style_emoticons/default')) {
try {
foreach (new DirectoryIterator(DOC_IPS_ROOT_PATH . 'style_emoticons/default') as $file) {
if (!$file->isDot()) {
$_name = $file->getFileName();
/* Annoyingly, isDot doesn't match .svn, etc */
if (substr($_name, 0, 1) == '.') {
continue;
}
if (@copy(DOC_IPS_ROOT_PATH . 'style_emoticons/default/' . $_name, IPS_PUBLIC_PATH . 'style_emoticons/default/' . $_name)) {
$output[] = "Смайлики: скопирован {$_name}...";
} else {
$output[] = "Не удалось скопировать {$_name} - после обновления перенесите его самостоятельно";
}
}
}
} catch (Exception $e) {
}
}
/* LOG IN METHODS */
$this->DB->build(array('select' => '*', 'from' => 'login_methods'));
$this->DB->execute();
while ($row = $this->DB->fetch()) {
$loginMethods[$row['login_folder_name']] = $row;
}
$count = 6;
$recount = array('internal' => 1, 'ipconverge' => 2, 'ldap' => 3, 'external' => 4);
/* Fetch XML */
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPSSetUp::charSet);
$xml->load(IPS_ROOT_PATH . 'setup/xml/loginauth.xml');
foreach ($xml->fetchElements('login_methods') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
$data['login_order'] = isset($recount[$data['login_folder_name']]) ? $recount[$data['login_folder_name']] : ++$count;
unset($data['login_id']);
if (!$loginMethods[$data['login_folder_name']]) {
$this->DB->insert('login_methods', $data);
} else {
$this->DB->update('login_methods', array('login_order' => $data['login_order']), 'login_folder_name=\'' . $data['login_folder_name'] . '\'');
}
}
/* Reset member languages and skins */
$this->DB->update('members', array('language' => IPSLib::getDefaultLanguage(), 'skin' => 0));
/* Empty caches */
$this->DB->delete('cache_store', "cs_key='forum_cache'");
$this->DB->delete('cache_store', "cs_key='skin_id_cache'");
/* Empty other tables */
$this->DB->delete('skin_cache');
$this->DB->delete('skin_templates_cache');
/* Reset admin permissions */
$this->DB->update('admin_permission_rows', array('row_perm_cache' => ''));
/* Drop Tables */
$this->DB->dropTable('contacts');
$this->DB->dropTable('skin_macro');
$this->DB->dropTable('skin_template_links');
$this->DB->dropTable('skin_templates_old');
$this->DB->dropTable('skin_sets');
$this->DB->dropTable('languages');
$this->DB->dropTable('topics_read');
$this->DB->dropTable('topic_markers');
$this->DB->dropTable('acp_help');
$this->DB->dropTable('members_converge');
$this->DB->dropTable('member_extra');
$this->DB->dropTable('custom_bbcode_old');
$this->DB->dropTable('admin_sessions');
$this->DB->dropTable('components');
$this->DB->dropTable('admin_permission_keys');
$this->DB->dropTable('conf_settings');
$this->DB->dropTable('conf_settings_titles');
$this->DB->dropTable('reg_antispam');
if (!$skipPms) {
$this->DB->dropTable('message_text');
$this->DB->dropTable('message_topics_old');
}
$message = (is_array($output) and count($output)) ? implode("<br />", $output) . '<br />' : '';
$this->registry->output->addMessage($message . "очистка SQL завершена...");
/* Last function, so unset workact */
$this->request['workact'] = '';
}
示例5: doMediaImport
/**
* Abstracted import routine for installer
*
* @access public
* @param string XML file content
* @return void
*/
public function doMediaImport($content)
{
//-----------------------------------------
// Get xml mah-do-dah
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
//-----------------------------------------
// Get current custom bbcodes
//-----------------------------------------
$tags = array();
$this->DB->build(array('select' => '*', 'from' => 'bbcode_mediatag'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$tags[$r['mediatag_name']] = $r['mediatag_id'];
}
//-----------------------------------------
// pArse
//-----------------------------------------
foreach ($xml->fetchElements('mediatag') as $mediatag) {
$entry = $xml->fetchElementsFromRecord($mediatag);
$name = $entry['mediatag_name'];
$match = $entry['mediatag_match'];
$replace = $entry['mediatag_replace'];
$array = array('mediatag_name' => $name, 'mediatag_match' => $match, 'mediatag_replace' => $replace);
if ($tags[$name]) {
$this->DB->update('bbcode_mediatag', $array, "mediatag_id=" . $tags[$name]);
continue;
}
if ($name) {
$this->DB->insert('bbcode_mediatag', $array);
}
}
$this->recacheMediaTag();
}
示例6: fetchXmlAppModules
/**
* Fetch Apps XML Modules File
*
* @access public
* @param string Application Directory
* @param string Charset (post install)
* @return array ..of data
*/
public static function fetchXmlAppModules($app, $charset = '')
{
//-----------------------------------------
// No modules?
//-----------------------------------------
if (!is_file(IPSLib::getAppDir($app) . '/xml/' . $app . '_modules.xml')) {
return array();
}
/* INIT */
$modules = array();
try {
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML($charset ? $charset : IPSSetUp::charSet);
$xml->load(IPSLib::getAppDir($app) . '/xml/' . $app . '_modules.xml');
/* Fetch info */
foreach ($xml->fetchElements('module') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
if ($data['sys_module_id']) {
unset($data['sys_module_id']);
}
/* Remove fields removed from 3.1.3+ to avoid driver errors */
unset($data['sys_module_parent']);
unset($data['sys_module_tables']);
unset($data['sys_module_hooks']);
$modules[$data['sys_module_key'] . intval($data['sys_module_admin'])] = $data;
}
return $modules;
} catch (Exception $error) {
return FALSE;
}
}
示例7: _loginInstall
/**
* Install a login method
*
* @return @e void [Outputs to screen]
*/
protected function _loginInstall()
{
//-----------------------------------------
// Get xml class
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
$login_id = basename(ipsRegistry::$request['login_folder']);
//-----------------------------------------
// Now get the XML data
//-----------------------------------------
$dh = opendir(IPS_PATH_CUSTOM_LOGIN);
if ($dh !== false) {
while (false !== ($file = readdir($dh))) {
if (is_dir(IPS_PATH_CUSTOM_LOGIN . '/' . $file) and $file == $login_id) {
if (is_file(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml')) {
$file_content = file_get_contents(IPS_PATH_CUSTOM_LOGIN . '/' . $file . '/loginauth_install.xml');
$xml->loadXML($file_content);
foreach ($xml->fetchElements('row') as $record) {
$data = $xml->fetchElementsFromRecord($record);
}
} else {
closedir($dh);
ipsRegistry::getClass('output')->global_message = $this->lang->words['l_installer404'];
$this->_loginList();
return;
}
$dir_methods[$file] = $data;
break;
}
}
closedir($dh);
}
if (!is_array($dir_methods) or !count($dir_methods)) {
ipsRegistry::getClass('output')->global_message = $this->lang->words['l_installer404'];
$this->_loginList();
return;
}
//-----------------------------------------
// Now verify it isn't installed
//-----------------------------------------
$login = $this->DB->buildAndFetch(array('select' => 'login_id', 'from' => 'login_methods', 'where' => "login_folder_name='" . $login_id . "'"));
if ($login['login_id']) {
ipsRegistry::getClass('output')->global_message = $this->lang->words['l_already'];
$this->_loginList();
return;
}
//-----------------------------------------
// Get the highest order and insert method
//-----------------------------------------
$max = $this->DB->buildAndFetch(array('select' => 'MAX(login_order) as highest_order', 'from' => 'login_methods'));
$dir_methods[$login_id]['login_order'] = $max['highest_order'] + 1;
$this->DB->insert('login_methods', $dir_methods[$login_id]);
//-----------------------------------------
// Recache
//-----------------------------------------
$this->loginsRecache();
ipsRegistry::getClass('output')->redirect($this->settings['base_url'] . $this->form_code . "", $this->lang->words['l_yesinstalled']);
}
示例8: rebuildMobileSkinUserAgentsFromSetDataXml
/**
* Rebuilds the mobile user agents from the skin set data
*/
public function rebuildMobileSkinUserAgentsFromSetDataXml()
{
/* Init */
$mobileSkinSet = $this->fetchSkinData($this->fetchSetIdByKey('mobile', true), true);
$xmlData = array();
/* Grab xml */
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML('UTF-8');
/* Skin Set Data */
$xml->load(IPS_ROOT_PATH . 'setup/xml/skins/setsData.xml');
foreach ($xml->fetchElements('set') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
if ($data['set_key'] == 'mobile') {
$xmlData = $data;
break;
}
}
/* Update */
if ($xmlData['set_key'] && IPSLib::isSerialized($xmlData['set_locked_uagent']) && IPSLib::isSerialized($mobileSkinSet['set_locked_uagent'])) {
$new = unserialize($xmlData['set_locked_uagent']);
$old = unserialize($mobileSkinSet['set_locked_uagent']);
/* Merge them */
foreach ($new['groups'] as $group) {
if (!in_array($group, $old['groups'])) {
$old['groups'][] = $group;
}
}
foreach ($new['uagents'] as $agent => $version) {
if (!in_array($agent, $new['uagents'])) {
$old['uagents'][$agent] = $version;
}
}
}
if (is_array($old) && count($old)) {
$this->DB->update('skin_collections', array('set_locked_uagent' => serialize($old)), "set_key='mobile'");
}
}
示例9: doExecute
/**
* Execute selected method
*
* @access public
* @param object Registry object
* @return @e void
*/
public function doExecute(ipsRegistry $registry)
{
/* INIT */
$filesOK = NULL;
$extensions = get_loaded_extensions();
$extensionsOK = TRUE;
$extensionData = array();
/* Test Extensions */
$INSTALLDATA = array();
include IPS_ROOT_PATH . 'setup/xml/requiredextensions.php';
/*noLibHook*/
if (is_array($INSTALLDATA) && count($INSTALLDATA)) {
foreach ($INSTALLDATA as $data) {
if (!in_array($data['testfor'], $extensions)) {
//-----------------------------------------
// Added 'nohault' key which will show a
// warning but not prohibit installation
//-----------------------------------------
if ($data['nohault']) {
$data['_ok'] = 1;
// Anything but true or false
$extensionsOK = 1;
// Anything but true or false
} else {
$extensionsOK = FALSE;
}
} else {
$data['_ok'] = TRUE;
}
$extensionData[] = $data;
}
}
/* Check for conf_global.dist.php */
if (is_file(DOC_IPS_ROOT_PATH . 'conf_global.dist.php') and !is_file(DOC_IPS_ROOT_PATH . 'conf_global.php')) {
if (!@rename(DOC_IPS_ROOT_PATH . 'conf_global.dist.php', DOC_IPS_ROOT_PATH . 'conf_global.php')) {
$filesOK = FALSE;
$this->registry->output->addError("<strong>You MUST rename the file 'conf_global.<b style='color:red'>dist.php</b>' TO 'conf_global.<b style='color:red'>php</b>' before continuing.</strong>\r\r\n\t\t\t\t\t\t\t \t\t\t\t\t\t This file can be found in the 'root' directory on your IP.Board install.");
}
}
/* All extensions loaded OK? */
if ($extensionsOK == TRUE and $filesOK === NULL) {
$filesOK = FALSE;
/* Fetch core writeable files */
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPSSetUp::charSet);
try {
$xml->load(IPS_ROOT_PATH . 'setup/xml/writeablefiles.xml');
foreach ($xml->fetchElements('file') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
if ($data['path']) {
$_path = DOC_IPS_ROOT_PATH . $data['path'];
if (!file_exists($_path)) {
if ($data['dir']) {
if (!@mkdir($_path, IPS_FOLDER_PERMISSION, TRUE)) {
$this->registry->output->addError('Directory does not exist: "' . $data['path'] . '", please create it via FTP');
}
} else {
$this->registry->output->addError('File does not exist: "' . $data['path'] . '", please create it via FTP');
}
}
if (!is_writeable($_path)) {
if (!@chmod($_path, is_dir($_path) ? IPS_FOLDER_PERMISSION : IPS_FILE_PERMISSION)) {
if (is_dir($_path)) {
$this->registry->output->addError('Can not write to directory: "' . $data['path'] . '", please CHMOD to 777');
} else {
$this->registry->output->addError('Can not write to file: "' . $data['path'] . '", please CHMOD to 777');
}
}
}
}
}
if (!count($this->registry->output->fetchErrors())) {
$filesOK = TRUE;
}
} catch (Exception $error) {
$filesOK = FALSE;
$this->registry->output->addError("Cannot locate: " . IPS_ROOT_PATH . 'setup/xml/writeablefiles.xml');
}
}
/* Hide buttons? */
if ($filesOK !== TRUE or $extensionsOK != TRUE) {
$this->registry->output->setNextAction('');
$this->registry->output->setHideButton(TRUE);
}
/* Simply return the requirements page */
$this->registry->output->setTitle("Requirements");
$this->registry->output->addContent($this->registry->output->template()->page_requirements($filesOK, $extensionsOK, $extensionData));
$this->registry->output->sendOutput();
}
示例10: applicationRemove
/**
* Remove an application
*
* @return @e void [Outputs to screen]
*/
public function applicationRemove()
{
//--------------------------------------------
// INIT
//--------------------------------------------
$app_id = intval($this->request['app_id']);
//-----------------------------------------
// Got an application?
//-----------------------------------------
$application = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'core_applications', 'where' => 'app_id=' . $app_id));
if (!$application['app_id']) {
$this->registry->output->global_message = $this->lang->words['a_noid'];
$this->applicationsOverview();
return;
}
//-----------------------------------------
// Protected?
//-----------------------------------------
if (!IN_DEV and $application['app_protected']) {
$this->registry->output->global_message = $this->lang->words['a_protectapp'];
$this->applicationsOverview();
return;
}
//-----------------------------------------
// Remove Settings
//-----------------------------------------
$this->DB->build(array('select' => '*', 'from' => 'core_sys_settings_titles', 'where' => "conf_title_app='{$application['app_directory']}'"));
$this->DB->execute();
$conf_title_id = array();
while ($r = $this->DB->fetch()) {
$conf_title_id[] = $r['conf_title_id'];
}
if (count($conf_title_id)) {
$this->DB->delete('core_sys_conf_settings', 'conf_group IN(' . implode(',', $conf_title_id) . ')');
}
$this->DB->delete('core_sys_settings_titles', "conf_title_app='{$application['app_directory']}'");
$settingsFile = IPSLib::getAppDir($application['app_directory']) . '/xml/' . $application['app_directory'] . '_settings.xml';
if (is_file($settingsFile)) {
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->load($settingsFile);
$keys = array();
foreach ($xml->fetchElements('setting') as $setting) {
$entry = $xml->fetchElementsFromRecord($setting);
if ($entry['conf_is_title']) {
continue;
}
$keys[] = "'{$entry['conf_key']}'";
}
if (!empty($keys)) {
$this->DB->delete('core_sys_conf_settings', 'conf_key IN(' . implode(',', $keys) . ')');
}
}
//-----------------------------------------
// Remove Application Caches
//-----------------------------------------
$_file = IPSLib::getAppDir($application['app_directory']) . '/extensions/coreVariables.php';
if (is_file($_file)) {
$CACHE = array();
require $_file;
/*noLibHook*/
if (is_array($CACHE) and count($CACHE)) {
foreach ($CACHE as $key => $data) {
$this->DB->delete('cache_store', "cs_key='{$key}'");
}
}
}
//-----------------------------------------
// Remove tables
//-----------------------------------------
$_file = IPSLib::getAppDir($application['app_directory']) . '/setup/versions/install/sql/' . $application['app_directory'] . '_' . ipsRegistry::dbFunctions()->getDriverType() . '_tables.php';
if (is_file($_file)) {
$TABLE = array();
require $_file;
/*noLibHook*/
foreach ($TABLE as $q) {
//-----------------------------------------
// Capture create tables first
//-----------------------------------------
preg_match("/CREATE TABLE (\\S+)(\\s)?\\(/", $q, $match);
if ($match[1]) {
$_table = preg_replace('#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\\S+)#", "\\1", $match[1]);
$this->DB->dropTable($_table);
} else {
//-----------------------------------------
// Then capture alter tables
//-----------------------------------------
preg_match("/ALTER TABLE (\\S+)\\sADD\\s(\\S+)\\s/i", $q, $match);
if ($match[1] and $match[2]) {
$_table = preg_replace('#^' . ipsRegistry::dbFunctions()->getPrefix() . "(\\S+)#", "\\1", $match[1]);
$_field = $match[2];
/* check for field */
if ($this->DB->checkForField($_field, $_table)) {
$this->DB->dropField($_table, $_field);
//.........这里部分代码省略.........
示例11: importTemplateAppXML
/**
* Import a single app
*
* @access public
* @param string App
* @param string Skin key to import
* @param int Set ID
* @param boolean Set the edited / added flags to 0 (from install, upgrade)
* @return mixed bool, or array of info
*/
public function importTemplateAppXML($app, $skinKey, $setID = 0, $ignoreAddedEditedFlag = false)
{
//-----------------------------------------
// INIT
//-----------------------------------------
$templateGroups = array();
$templates = array();
$fileXML = IPSLib::getAppDir($app) . '/xml/' . $app . '_' . $skinKey . '_templates.xml';
$infoXML = IPSLib::getAppDir($app) . '/xml/information.xml';
$return = array('updateCount' => 0, 'insertCount' => 0, 'updateBits' => array(), 'insertBits' => array());
if (!file_exists($fileXML)) {
return $return;
}
if (!$setID and $skinKey != 'root') {
/* Figure out correct set ID based on key */
$skinSetData = $this->DB->buildAndFetch(array('select' => '*', 'from' => 'skin_collections', 'where' => "set_key='" . $skinKey . "'"));
$setID = $skinSetData['set_id'];
}
/* Set ignore flag correctly */
if (!empty($skinKey) and in_array($skinKey, array('root', 'lofi', 'xmlskin'))) {
$ignoreAddedEditedFlag = true;
}
//-----------------------------------------
// XML
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
//-----------------------------------------
// Get information file
//-----------------------------------------
$xml->load($infoXML);
foreach ($xml->fetchElements('template') as $template) {
$name = $xml->fetchItem($template);
$match = $xml->fetchAttribute($template, 'match');
if ($name) {
$templateGroups[$name] = $match;
}
}
if (!is_array($templateGroups) or !count($templateGroups)) {
$this->_addMessage("Nothing to export for " . $app);
return FALSE;
}
//-----------------------------------------
// Fetch templates
//-----------------------------------------
$_templates = $this->fetchTemplates($setID, 'allNoContent');
$_MASTER = $this->fetchTemplates(0, 'allNoContent');
//-----------------------------------------
// Loop through...
//-----------------------------------------
foreach ($_templates as $group => $data) {
$_okToGo = FALSE;
foreach ($templateGroups as $name => $match) {
if ($match == 'contains') {
if (stristr($group, $name)) {
$_okToGo = TRUE;
break;
}
} else {
if ($group == $name) {
$_okToGo = TRUE;
}
}
}
if ($_okToGo === TRUE) {
foreach ($data as $name => $templateData) {
$templates[$group][$name] = $templateData;
}
}
}
//-----------------------------------------
// Wipe the master skins
//-----------------------------------------
if ($setID == 0) {
$this->DB->delete('skin_templates', "template_set_id=0 AND template_group IN ('" . implode("','", array_keys($templates)) . "') AND template_user_added=0 AND template_added_to=0");
/* Now wipe the array so we enforce creation */
unset($templates);
}
//-----------------------------------------
// Now grab the actual XML files
//-----------------------------------------
$xml->load($fileXML);
foreach ($xml->fetchElements('template') as $templatexml) {
$data = $xml->fetchElementsFromRecord($templatexml);
/* Figure out if this is added by a user or not */
if ($ignoreAddedEditedFlag === TRUE) {
$isAdded = 0;
$isEdited = 0;
} else {
$isAdded = (is_array($_MASTER[$data['template_group']][strtolower($data['template_name'])]) and !$_MASTER[$data['template_group']][strtolower($data['template_name'])]['template_user_added']) ? 0 : 1;
//.........这里部分代码省略.........
示例12: imprtFromXML
//.........这里部分代码省略.........
$content = '';
foreach ($xmlarchive->asArray() as $k => $f) {
if ($k == 'language_entries.xml') {
$content = $f['content'];
break;
}
}
//-----------------------------------------
// No content from de-archiving, must not
// be archive, but rather raw XML file
//-----------------------------------------
if ($content == '' and strpos($uploadedContent, "<languageexport") !== false) {
$content = $uploadedContent;
}
}
//-----------------------------------------
// Make sure we have content
//-----------------------------------------
if (!$content) {
$this->registry->output->global_message = $this->lang->words['l_badfile'];
$this->languagesList();
return;
}
//-----------------------------------------
// Get xml class
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
//-----------------------------------------
// Is this full language pack?...
//-----------------------------------------
foreach ($xml->fetchElements('langinfo') as $lang_data) {
$lang_info = $xml->fetchElementsFromRecord($lang_data);
$lang_data = array('lang_short' => $lang_info['lang_short'], 'lang_title' => $lang_info['lang_title']);
}
$lang_ids = array();
$insertId = 0;
//-----------------------------------------
// Do we have language pack info?
//-----------------------------------------
if ($lang_data['lang_short']) {
//-----------------------------------------
// Does this pack already exist
//-----------------------------------------
$update_lang = $this->DB->buildAndFetch(array('select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_short='{$lang_data['lang_short']}'"));
//-----------------------------------------
// If doesn't exist, then create new pack
//-----------------------------------------
if (!$update_lang['lang_id']) {
$this->DB->insert('core_sys_lang', $lang_data);
$insertId = $this->DB->getInsertId();
if (@mkdir(IPS_CACHE_PATH . '/cache/lang_cache/' . $insertId)) {
@file_put_contents(IPS_CACHE_PATH . 'cache/lang_cache/' . $insertId . '/index.html', '');
@chmod(IPS_CACHE_PATH . '/cache/lang_cache/' . $insertId, 0777);
}
//-----------------------------------------
// Copy over language bits from default lang
//-----------------------------------------
$default = $this->DB->buildAndFetch(array('select' => 'lang_id', 'from' => 'core_sys_lang', 'where' => "lang_default=1"));
$this->DB->build(array('select' => 'word_app,word_pack,word_key,word_default', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$default['lang_id']}"));
$q = $this->DB->execute();
while ($r = $this->DB->fetch($q)) {
$r['lang_id'] = $insertId;
$this->DB->insert('core_sys_lang_words', $r);
}
示例13: _importBlock
/**
* Import skin templates for a plugin block
*
* @access protected
* @return void
*/
protected function _importBlock()
{
//-----------------------------------------
// Developer reimporting templates?
//-----------------------------------------
if ($this->request['dev']) {
$templates = array();
$this->DB->build(array('select' => '*', 'from' => 'ccs_template_blocks'));
$outer = $this->DB->execute();
while ($r = $this->DB->fetch($outer)) {
if (!preg_match("/_(\\d+)\$/", $r['tpb_name'])) {
$templates[$r['tpb_name']] = $r;
}
}
$content = file_get_contents(IPSLib::getAppDir('ccs') . '/xml/block_templates.xml');
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
foreach ($xml->fetchElements('template') as $template) {
$_template = $xml->fetchElementsFromRecord($template);
if ($_template['tpb_name']) {
unset($_template['tpb_id']);
if (array_key_exists($_template['tpb_name'], $templates)) {
$this->DB->update("ccs_template_blocks", $_template, "tpb_id={$templates[$_template['tpb_name']]['tpb_id']}");
} else {
$this->DB->insert("ccs_template_blocks", $_template);
}
}
}
$this->registry->output->global_message = $this->lang->words['block_import_devgood'];
$this->registry->output->silentRedirectWithMessage($this->settings['base_url'] . '&module=blocks§ion=blocks');
}
$content = $this->registry->getClass('adminFunctions')->importXml();
//-----------------------------------------
// Get xml class
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
//-----------------------------------------
// First, found out if this is just a plugin
//-----------------------------------------
$_fullBlock = false;
$_block = array();
$_blockId = 0;
foreach ($xml->fetchElements('block') as $block) {
$_block = $xml->fetchElementsFromRecord($block);
}
if (count($_block)) {
$_fullBlock = true;
}
//-----------------------------------------
// If full block, insert block first to get id
//-----------------------------------------
if ($_fullBlock) {
unset($_block['block_id']);
unset($_block['block_cache_last']);
unset($_block['block_position']);
unset($_block['block_category']);
$check = $this->DB->buildAndFetch(array('select' => 'block_id', 'from' => 'ccs_blocks', 'where' => "block_key='{$_block['block_key']}'"));
//-----------------------------------------
// Instead of updating, just change key to prevent
// overwriting someone's configured block
//-----------------------------------------
if ($check['block_id']) {
$_block['block_key'] = $_block['block_key'] . md5(uniqid(microtime()));
}
$this->DB->insert('ccs_blocks', $_block);
$_blockId = $this->DB->getInsertId();
}
//-----------------------------------------
// Do the template regardless
//-----------------------------------------
$tpbId = 0;
foreach ($xml->fetchElements('template') as $template) {
$entry = $xml->fetchElementsFromRecord($template);
if (!$entry['tpb_name']) {
continue;
}
$templatebit = array('tpb_name' => $entry['tpb_name'], 'tpb_params' => $entry['tpb_params'], 'tpb_content' => $entry['tpb_content']);
//-----------------------------------------
// Fix name if full block
//-----------------------------------------
if ($_fullBlock) {
$templatebit['tpb_name'] = preg_replace("/^(.+?)_(\\d+)\$/", "\\1_{$_blockId}", $templatebit['tpb_name']);
}
$check = $this->DB->buildAndFetch(array('select' => 'tpb_id', 'from' => 'ccs_template_blocks', 'where' => "tpb_name='{$entry['tpb_name']}'"));
if ($check['tpb_id']) {
$this->DB->update('ccs_template_blocks', $templatebit, 'tpb_id=' . $check['tpb_id']);
$tpbId = $check['tpb_id'];
} else {
$this->DB->insert('ccs_template_blocks', $templatebit);
$tpbId = $this->DB->getInsertId();
}
//.........这里部分代码省略.........
示例14: createSession
/**
* Create new session
*
* @access public
* @param string Diff session title
* @param string Compare HTML
* @param boolean Ignore new bits
* @return int New session ID
*/
public function createSession($title, $content, $ignoreBits = FALSE)
{
//-----------------------------------------
// INIT
//-----------------------------------------
$templateBits = array();
//-----------------------------------------
// Get number for missing template bits
//-----------------------------------------
$_bits = $this->DB->buildAndFetch(array('select' => 'COUNT(*) as count', 'from' => 'skin_templates', 'where' => 'template_set_id=0'));
//-----------------------------------------
// Create session
//-----------------------------------------
$this->DB->allow_sub_select = 1;
$this->DB->insert('template_diff_session', array('diff_session_togo' => intval($_bits['count']), 'diff_session_done' => 0, 'diff_session_title' => $title, 'diff_session_updated' => time(), 'diff_session_ignore_missing' => $ignoreBits === TRUE ? 1 : 0));
$diffSesssionID = $this->DB->getInsertId();
//-----------------------------------------
// XML
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
//-----------------------------------------
// Check to see if its an archive...
//-----------------------------------------
if (strstr($content, "<xmlarchive")) {
/* It's an archive... */
require IPS_KERNEL_PATH . 'classXMLArchive.php';
$xmlArchive = new classXMLArchive(IPS_KERNEL_PATH);
$xmlArchive->readXML($content);
/* We just want the templates.. */
foreach ($xmlArchive->asArray() as $path => $fileData) {
if ($fileData['path'] == 'templates') {
$xml->loadXML($fileData['content']);
foreach ($xml->fetchElements('template') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
if (is_array($data)) {
$templateBits[] = $data;
}
}
}
}
} else {
$xml->loadXML($content);
foreach ($xml->fetchElements('template') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
if (is_array($data)) {
$templateBits[] = $data;
}
}
}
//-----------------------------------------
// Got anything?
//-----------------------------------------
if (!count($templateBits)) {
return FALSE;
}
//-----------------------------------------
// Build session data
//-----------------------------------------
foreach ($templateBits as $bit) {
$diffKey = $diffSesssionID . ':' . $bit['template_group'] . ':' . $bit['template_name'];
if (!$seen[$diffKey]) {
$this->DB->allow_sub_select = 1;
$this->DB->insert('templates_diff_import', array('diff_key' => $diffKey, 'diff_func_group' => $bit['template_group'], 'diff_func_data' => $bit['template_data'], 'diff_func_name' => $bit['template_name'], 'diff_func_content' => $bit['template_content'], 'diff_session_id' => $diffSesssionID));
$seen[$diffKey] = 1;
}
}
return $diffSesssionID;
}
示例15: badwordsImport
/**
* Import badwords from an xml file
*
* @return @e void
*/
public function badwordsImport()
{
/* Get Badwords XML */
try {
$content = $this->registry->adminFunctions->importXml('ipb_badwords.xml');
} catch (Exception $e) {
$this->registry->output->showError($e->getMessage());
}
/* Check for content */
if (!$content) {
$this->registry->output->global_message = $this->lang->words['bwl_upload_failed'];
$this->badwordsOvervew();
return;
}
//-----------------------------------------
// Get xml class
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
if (!count($xml->fetchElements('badword'))) {
$this->registry->output->global_message = $this->lang->words['bwl_upload_wrong'];
$this->badwordsOvervew();
return;
}
/* Get a list of current badwords */
$words = array();
$this->DB->build(array('select' => '*', 'from' => 'badwords', 'order' => 'type'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$words[$r['type']] = 1;
}
/* Loop through the xml document and insert new bad words */
foreach ($xml->fetchElements('badword') as $badword) {
$entry = $xml->fetchElementsFromRecord($badword);
/* Get the filter settings */
$type = $entry['type'];
$swop = $entry['swop'];
$m_exact = $entry['m_exact'];
/* Skip if it's already in the db */
if ($words[$type]) {
continue;
}
/* Add to the db */
if ($type) {
$this->DB->insert('badwords', array('type' => $type, 'swop' => $swop, 'm_exact' => $m_exact));
}
}
/* Rebuild cache and bounce */
$this->badwordsRebuildCache();
$this->registry->output->global_message = $this->lang->words['bwl_upload_good'];
$this->badwordsOvervew();
}