本文整理汇总了PHP中classXML::loadXML方法的典型用法代码示例。如果您正苦于以下问题:PHP classXML::loadXML方法的具体用法?PHP classXML::loadXML怎么用?PHP classXML::loadXML使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类classXML
的用法示例。
在下文中一共展示了classXML::loadXML方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _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);
}
}
示例2: _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);
}
}
}
}
示例3: writeDefaults
/**
* Write Default Values
*/
public function writeDefaults()
{
$defaultTemplates = file_get_contents(IPS_ROOT_PATH . 'setup/xml/system_templates.xml');
if (!class_exists('classXML')) {
require_once IPS_KERNEL_PATH . 'classXML.php';
}
$xml = new classXML('utf-8');
$xml->loadXML($defaultTemplates);
$array = $xml->fetchXMLAsArray();
foreach ($array['system_templates']['template'] as $template) {
$params = array();
foreach ($template['params']['param'] as $p) {
$params[] = $p['#alltext'];
}
$this->write($template['key']['#alltext'], $params, $template['content']['#alltext']);
}
}
示例4: taskImport
/**
* Perform the task import
*
* @access public
* @param string Raw XML code
* @return void
*/
public function taskImport()
{
$content = $this->registry->getClass('adminFunctions')->importXml();
//-----------------------------------------
// Got anything?
//-----------------------------------------
if (!$content) {
$this->registry->output->global_message = $this->lang->words['tupload_failed'];
$this->_bbcodeStart();
return;
}
//-----------------------------------------
// Get xml class
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
//-----------------------------------------
// Get current custom bbcodes
//-----------------------------------------
$tasks = array();
$this->DB->build(array('select' => '*', 'from' => 'task_manager'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$tasks[$r['task_key']] = 1;
}
//-----------------------------------------
// pArse
//-----------------------------------------
foreach ($xml->fetchElements('row') as $task) {
$entry = $xml->fetchElementsFromRecord($task);
unset($entry['task_id']);
unset($entry['task_next_run']);
/* Update */
$entry['task_cronkey'] = $entry['task_cronkey'] ? $entry['task_cronkey'] : md5(uniqid(microtime()));
$entry['task_next_run'] = $entry['task_next_run'] ? $entry['task_next_run'] : time();
$entry['task_description'] = $entry['task_description'] ? $entry['task_description'] : '';
if ($tasks[$entry['task_key']]) {
$this->DB->update('task_manager', $entry, "task_key='" . $entry['task_key'] . "'");
} else {
$this->DB->insert('task_manager', $entry);
}
}
//-----------------------------------------
// Output
//-----------------------------------------
/* Bounce */
$this->registry->output->global_message = $this->lang->words['t_simport_success'];
$this->taskManagerOverview();
}
示例5: installHook
/**
* Public install hook so we can use it in the installer and elsewhere
*
* @param string XML data
* @param boolean Add message to output->global_message
* @param boolean Allow skins to recache
* @param int Install enabled
* @return @e void
*/
public function installHook($content, $addMessage = FALSE, $allowSkinRecache = TRUE, $enabled = 1)
{
//-----------------------------------------
// Hooks directory writable?
//-----------------------------------------
if (!is_writable(IPS_HOOKS_PATH)) {
if (!$addMessage) {
return false;
}
$this->registry->output->showError($this->lang->words['h_dir_notwritable'], 111159);
}
//-----------------------------------------
// Got our hooks?
//-----------------------------------------
if (!is_array($this->hooks) or !count($this->hooks)) {
$this->DB->build(array('select' => '*', 'from' => 'core_hooks'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$this->hooks[$r['hook_key']] = $r;
}
}
//-----------------------------------------
// Get xml mah-do-dah
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
//-----------------------------------------
// Unpack the datafile
//-----------------------------------------
$xml->loadXML($content);
foreach ($xml->fetchElements('config') as $data) {
$config = $xml->fetchElementsFromRecord($data);
if (!count($config)) {
$this->registry->output->showError($this->lang->words['h_xmlwrong'], 1111);
}
}
//-----------------------------------------
// Temp
//-----------------------------------------
$tempExtraData = unserialize($config['hook_extra_data']);
//-----------------------------------------
// Set config
//-----------------------------------------
$config = array('hook_name' => $config['hook_name'], 'hook_desc' => $config['hook_desc'], 'hook_author' => $config['hook_author'], 'hook_email' => $config['hook_email'], 'hook_website' => $config['hook_website'], 'hook_update_check' => $config['hook_update_check'], 'hook_requirements' => $config['hook_requirements'], 'hook_version_human' => $config['hook_version_human'], 'hook_version_long' => $config['hook_version_long'], 'hook_key' => $config['hook_key'], 'hook_global_caches' => $config['hook_global_caches'], 'hook_enabled' => $enabled, 'hook_updated' => IPS_UNIX_TIME_NOW);
$extra_data = array();
//-----------------------------------------
// Set files
//-----------------------------------------
$files = array();
foreach ($xml->fetchElements('hookfiles') as $node) {
foreach ($xml->fetchElements('file', $node) as $_file) {
$file = $xml->fetchElementsFromRecord($_file);
if ($file['hook_type']) {
$files[] = array('hook_file_real' => $file['hook_file_real'], 'hook_type' => $file['hook_type'], 'hook_classname' => $file['hook_classname'], 'hook_data' => $file['hook_data'], 'hooks_source' => $file['hooks_source']);
}
}
}
//-----------------------------------------
// Set the custom script
//-----------------------------------------
$custom = array();
$customClass = null;
foreach ($xml->fetchElements('hookextras_custom') as $node) {
foreach ($xml->fetchElements('file', $node) as $_file) {
$file = $xml->fetchElementsFromRecord($_file);
if (count($file)) {
$custom = array('filename' => $file['filename'], 'source' => $file['source']);
}
}
}
/* Got any custom file to initialize? */
if ($custom['filename'] && $custom['source']) {
# Our dirty trick to avoid saving the file on disk just yet...
$_custom = preg_replace('#^(\\s*)<\\?(php)+#i', '', $custom['source']);
eval($_custom);
$classname = str_replace('.php', '', $custom['filename']);
if (class_exists($classname)) {
$customClass = new $classname($this->registry);
if (method_exists($customClass, 'pre_install')) {
$customClass->pre_install();
}
}
}
//-----------------------------------------
// Set the settings
//-----------------------------------------
$settings = array();
$settingGroups = array();
foreach ($xml->fetchElements('hookextras_settings') as $node) {
foreach ($xml->fetchElements('setting', $node) as $_setting) {
//.........这里部分代码省略.........
示例6: installHook
/**
* Public install hook so we can use it in the installer and elsewhere
*
* @access public
* @param string XML data
* @param boolean Add message to output->global_message
* @param boolean Allow skins to recache
* @param int Install enabled
* @return void
*/
public function installHook($content, $addMessage = FALSE, $allowSkinRecache = TRUE, $enabled = 1)
{
//-----------------------------------------
// Hooks directory writable?
//-----------------------------------------
if (!is_writable(IPS_HOOKS_PATH)) {
if (!$addMessage) {
return false;
}
$this->registry->output->showError($this->lang->words['h_dir_notwritable'], 111159);
}
//-----------------------------------------
// Got our hooks?
//-----------------------------------------
if (!is_array($this->hooks) or !count($this->hooks)) {
$this->DB->build(array('select' => '*', 'from' => 'core_hooks'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$this->hooks[$r['hook_key']] = $r;
}
}
//-----------------------------------------
// Get xml mah-do-dah
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
//-----------------------------------------
// Unpack the datafile
//-----------------------------------------
$xml->loadXML($content);
foreach ($xml->fetchElements('config') as $data) {
$config = $xml->fetchElementsFromRecord($data);
if (!count($config)) {
$this->registry->output->showError($this->lang->words['h_xmlwrong'], 1111);
}
}
//-----------------------------------------
// Temp
//-----------------------------------------
$tempExtraData = unserialize($config['hook_extra_data']);
//-----------------------------------------
// Set config
//-----------------------------------------
$config = array('hook_name' => $config['hook_name'], 'hook_desc' => $config['hook_desc'], 'hook_author' => $config['hook_author'], 'hook_email' => $config['hook_email'], 'hook_website' => $config['hook_website'], 'hook_update_check' => $config['hook_update_check'], 'hook_requirements' => $config['hook_requirements'], 'hook_version_human' => $config['hook_version_human'], 'hook_version_long' => $config['hook_version_long'], 'hook_key' => $config['hook_key'], 'hook_enabled' => $enabled, 'hook_updated' => time());
$extra_data = array();
//-----------------------------------------
// Set files
//-----------------------------------------
$files = array();
foreach ($xml->fetchElements('hookfiles') as $node) {
foreach ($xml->fetchElements('file', $node) as $_file) {
$file = $xml->fetchElementsFromRecord($_file);
if ($file['hook_type']) {
$files[] = array('hook_file_real' => $file['hook_file_real'], 'hook_type' => $file['hook_type'], 'hook_classname' => $file['hook_classname'], 'hook_data' => $file['hook_data'], 'hooks_source' => $file['hooks_source']);
}
}
}
//-----------------------------------------
// Set the custom script
//-----------------------------------------
$custom = array();
foreach ($xml->fetchElements('hookextras_custom') as $node) {
foreach ($xml->fetchElements('file', $node) as $_file) {
$file = $xml->fetchElementsFromRecord($_file);
if (count($file)) {
$custom = array('filename' => $file['filename'], 'source' => $file['source']);
}
}
}
//-----------------------------------------
// Set the settings
//-----------------------------------------
$settings = array();
$settingGroups = array();
foreach ($xml->fetchElements('hookextras_settings') as $node) {
foreach ($xml->fetchElements('setting', $node) as $_setting) {
$setting = $xml->fetchElementsFromRecord($_setting);
if ($setting['conf_is_title'] == 1) {
$settingGroups[] = array('conf_title_title' => $setting['conf_title_title'], 'conf_title_desc' => $setting['conf_title_desc'], 'conf_title_noshow' => $setting['conf_title_noshow'], 'conf_title_keyword' => $setting['conf_title_keyword'], 'conf_title_app' => $setting['conf_title_app'], 'conf_title_tab' => $setting['conf_title_tab']);
} else {
$settings[] = array('conf_title' => $setting['conf_title'], 'conf_description' => $setting['conf_description'], 'conf_group' => $setting['conf_group'], 'conf_type' => $setting['conf_type'], 'conf_key' => $setting['conf_key'], 'conf_default' => $setting['conf_default'], 'conf_extra' => $setting['conf_extra'], 'conf_evalphp' => $setting['conf_evalphp'], 'conf_protected' => $setting['conf_protected'], 'conf_position' => $setting['conf_position'], 'conf_start_group' => $setting['conf_start_group'], 'conf_end_group' => $setting['conf_end_group'], 'conf_add_cache' => $setting['conf_add_cache'], 'conf_title_keyword' => $setting['conf_title_keyword']);
}
}
}
//-----------------------------------------
// Set the lang bits
//-----------------------------------------
$language = array();
foreach ($xml->fetchElements('hookextras_language') as $node) {
foreach ($xml->fetchElements('language', $node) as $_langbit) {
//.........这里部分代码省略.........
示例7: bbcodeImportDo
/**
* Perform the BBcode import
* Abstracted here so the installer can use it (and potentially other apps)
*
* @param string Raw XML code
* @return array [ 'inserted' => int, 'updated' => int ]
*/
public function bbcodeImportDo($content, $app = 'core')
{
/* Init vars */
$tags = array();
$return = array('updated' => 0, 'inserted' => 0);
//-----------------------------------------
// Got anything?
//-----------------------------------------
$content = trim($content);
if (empty($content)) {
return $return;
}
//-----------------------------------------
// Get xml class
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
//-----------------------------------------
// Get current custom bbcodes
//-----------------------------------------
$this->DB->build(array('select' => '*', 'from' => 'custom_bbcode'));
$this->DB->execute();
while ($r = $this->DB->fetch()) {
$tags[$r['bbcode_tag']] = 1;
}
//-----------------------------------------
// pArse
//-----------------------------------------
foreach ($xml->fetchElements('bbcode') as $bbcode) {
$entry = $xml->fetchElementsFromRecord($bbcode);
$bbcode_title = $entry['bbcode_title'];
$bbcode_desc = $entry['bbcode_desc'];
$bbcode_tag = $entry['bbcode_tag'];
$bbcode_replace = $entry['bbcode_replace'];
$bbcode_useoption = $entry['bbcode_useoption'];
$bbcode_example = $entry['bbcode_example'];
$bbcode_switch_option = $entry['bbcode_switch_option'];
$bbcode_menu_option_text = $entry['bbcode_menu_option_text'];
$bbcode_menu_content_text = $entry['bbcode_menu_content_text'];
$bbcode_single_tag = $entry['bbcode_single_tag'];
$bbcode_php_plugin = $entry['bbcode_php_plugin'];
$bbcode_no_parsing = $entry['bbcode_no_parsing'];
$bbcode_optional_option = $entry['bbcode_optional_option'];
$bbcode_aliases = $entry['bbcode_aliases'];
$bbcode_image = $entry['bbcode_image'];
$bbcode_app = $entry['bbcode_app'] ? $entry['bbcode_app'] : $app;
$bbcode_protected = $entry['bbcode_protected'] ? $entry['bbcode_protected'] : 0;
$bbcode_sections = $entry['bbcode_sections'] ? $entry['bbcode_sections'] : 'all';
$bbcode_regex = $entry['bbcode_custom_regex'] ? $entry['bbcode_custom_regex'] : '';
if ($tags[$bbcode_tag]) {
$bbarray = array('bbcode_title' => $bbcode_title, 'bbcode_desc' => $bbcode_desc, 'bbcode_tag' => $bbcode_tag, 'bbcode_replace' => IPSText::safeslashes($bbcode_replace), 'bbcode_useoption' => $bbcode_useoption, 'bbcode_example' => $bbcode_example, 'bbcode_switch_option' => $bbcode_switch_option, 'bbcode_menu_option_text' => $bbcode_menu_option_text, 'bbcode_menu_content_text' => $bbcode_menu_content_text, 'bbcode_php_plugin' => $bbcode_php_plugin, 'bbcode_no_parsing' => $bbcode_no_parsing, 'bbcode_optional_option' => $bbcode_optional_option, 'bbcode_aliases' => $bbcode_aliases, 'bbcode_image' => $bbcode_image, 'bbcode_single_tag' => $bbcode_single_tag, 'bbcode_app' => $bbcode_app, 'bbcode_protected' => $bbcode_protected, 'bbcode_custom_regex' => $bbcode_regex);
$this->DB->update('custom_bbcode', $bbarray, "bbcode_tag='" . $bbcode_tag . "'");
$return['updated']++;
continue;
}
if ($bbcode_tag) {
$bbarray = array('bbcode_title' => $bbcode_title, 'bbcode_desc' => $bbcode_desc, 'bbcode_tag' => $bbcode_tag, 'bbcode_replace' => IPSText::safeslashes($bbcode_replace), 'bbcode_useoption' => $bbcode_useoption, 'bbcode_example' => $bbcode_example, 'bbcode_switch_option' => $bbcode_switch_option, 'bbcode_menu_option_text' => $bbcode_menu_option_text, 'bbcode_menu_content_text' => $bbcode_menu_content_text, 'bbcode_groups' => 'all', 'bbcode_sections' => $bbcode_sections, 'bbcode_php_plugin' => $bbcode_php_plugin, 'bbcode_no_parsing' => $bbcode_no_parsing, 'bbcode_optional_option' => $bbcode_optional_option, 'bbcode_aliases' => $bbcode_aliases, 'bbcode_image' => $bbcode_image, 'bbcode_single_tag' => $bbcode_single_tag, 'bbcode_app' => $bbcode_app, 'bbcode_protected' => $bbcode_protected, 'bbcode_custom_regex' => $bbcode_regex);
$this->DB->insert('custom_bbcode', $bbarray);
$return['inserted']++;
}
}
$this->bbcodeRebuildCache();
return $return;
}
示例8: 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) {
if ($no_return) {
return;
}
$this->registry->output->global_message = $this->lang->words['l_badfile'];
$this->languagesList();
return;
}
//-----------------------------------------
// Get xml class
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML($skip_charset ? 'utf-8' : 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, IPS_FOLDER_PERMISSION);
}
//-----------------------------------------
// 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,word_js', 'from' => 'core_sys_lang_words', 'where' => "lang_id={$default['lang_id']}"));
示例9: applicationsMenuDataRecache
/**
* Recache menu data
*
* @return @e void
*/
public function applicationsMenuDataRecache()
{
$app_menu_cache = array();
$modules_cache = array();
//-----------------------------------------
// Get module data first in one query
//-----------------------------------------
$this->DB->build(array('select' => '*', 'from' => 'core_sys_module', 'where' => 'sys_module_visible=1 AND sys_module_admin=1', 'order' => 'sys_module_position ASC'));
$this->DB->execute();
while ($module = $this->DB->fetch()) {
$modules_cache[$module['sys_module_application']][] = $module['sys_module_key'];
}
//-----------------------------------------
// Now get applications and loop
//-----------------------------------------
$this->DB->build(array('select' => '*', 'from' => 'core_applications', 'order' => 'app_position ASC'));
$outer = $this->DB->execute();
while ($row = $this->DB->fetch($outer)) {
$app_dir = $row['app_directory'];
$main_items = $modules_cache[$app_dir];
//-----------------------------------------
// Continue...
//-----------------------------------------
if (count($main_items)) {
foreach ($main_items as $_current_module) {
$_file = IPSLib::getAppDir($app_dir) . "/modules_admin/" . $_current_module . '/xml/menu.xml';
if (is_file($_file)) {
//-----------------------------------------
// Get xml mah-do-dah
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
$content = @file_get_contents($_file);
if ($content) {
$xml->loadXML($content);
$menu = $xml->fetchXMLAsArray();
$item = array();
$subItemIndex = 0;
$itemIndex = 0;
/**
* Easiest way I could find to get the data in a proper multi-dimensional array
*/
foreach ($menu as $id => $data) {
foreach ($data as $dataKey => $dataValue) {
if ($dataKey == 'tabitems') {
foreach ($dataValue as $tabitemsKey => $tabItemsValue) {
if ($tabitemsKey == 'item') {
foreach ($tabItemsValue as $itemKey => $itemValue) {
if (is_int($itemKey)) {
foreach ($itemValue as $_itemKey => $_itemValue) {
$subItemIndex = 0;
if ($_itemKey == 'title' or $_itemKey == 'condition') {
$item[$itemIndex][$_itemKey] = $_itemValue['#alltext'];
} else {
if ($_itemKey == 'subitems') {
foreach ($_itemValue as $subitemKey => $subitemValue) {
if ($subitemKey != '#alltext') {
foreach ($subitemValue as $subitemRealKey => $subitemRealValue) {
if (is_int($subitemRealKey)) {
foreach ($subitemRealValue as $_subitemRealKey => $_subitemRealValue) {
if ($_subitemRealKey != '#alltext') {
$item[$itemIndex][$_itemKey][$subitemKey][$subItemIndex][$_subitemRealKey] = $_subitemRealValue['#alltext'];
}
}
} else {
if ($subitemRealKey != '#alltext') {
$item[$itemIndex][$_itemKey][$subitemKey][$subItemIndex][$subitemRealKey] = $subitemRealValue['#alltext'];
}
}
if (is_int($subitemRealKey)) {
$subItemIndex++;
}
}
$subItemIndex++;
}
}
}
}
}
$itemIndex++;
} else {
if ($itemKey == 'title') {
$item[$itemIndex][$itemKey] = $itemValue['#alltext'];
} else {
if ($itemKey == 'subitems') {
foreach ($itemValue as $subitemKey => $subitemValue) {
if ($subitemKey != '#alltext') {
foreach ($subitemValue as $subitemRealKey => $subitemRealValue) {
if (is_int($subitemRealKey)) {
foreach ($subitemRealValue as $_subitemRealKey => $_subitemRealValue) {
if ($_subitemRealKey != '#alltext') {
$item[$itemIndex][$itemKey][$subitemKey][$subItemIndex][$_subitemRealKey] = $_subitemRealValue['#alltext'];
}
}
//.........这里部分代码省略.........
示例10: parseInfoXML
/**
* Parses an info XML file
*
* @access public
* @param string XML
* @return array
*/
public function parseInfoXML($xmlContents)
{
//-----------------------------------------
// XML
//-----------------------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
$xml = new classXML(IPS_DOC_CHAR_SET);
//-----------------------------------------
// Get information file
//-----------------------------------------
$xml->loadXML($xmlContents);
foreach ($xml->fetchElements('data') as $xmlelement) {
$data = $xml->fetchElementsFromRecord($xmlelement);
}
return $data;
}
示例11: convert_polls
/**
* Convert Polls
*
* @access private
* @return void
**/
private function convert_polls()
{
print 'Need data to finish this section';
exit;
//---------------------------
// Set up
//---------------------------
$main = array('select' => 'PostID, ThreadID, PostAuthor, UserID, CAST(Subject AS varchar) as Subject, PostDate, IsApproved, CAST(Body AS TEXT) as Body, IPAddress, SectionID', 'from' => 'cs_Posts', 'where' => "PostType = '2'", 'order' => 't.pollid ASC');
$loop = $this->lib->load('polls', $main, array('voters'));
//---------------------------
// Loop
//---------------------------
require_once IPS_KERNEL_PATH . 'classXML.php';
while ($row = ipsRegistry::DB('hb')->fetch($this->lib->queryRes)) {
$xml = new classXML(IPSSetUp::charSet);
$xml->loadXML($row['Body']);
foreach ($xml->fetchElements('VoteOptions') as $option) {
$data = $this->_xml->fetchElementsFromRecord($_el);
if ($data['appears'] and intval($data['frequency']) > $this->_minF) {
return TRUE;
}
}
//-----------------------------------------
// Convert votes
//-----------------------------------------
$votes = array();
ipsRegistry::DB('hb')->build(array('select' => '*', 'from' => 'pollvoted', 'where' => "pollid='{$row['pollid']}' AND registered='1'"));
$voterRes = ipsRegistry::DB('hb')->execute();
while ($voter = ipsRegistry::DB('hb')->fetch($voterRes)) {
$vsave = array('vote_date' => time(), 'tid' => $row['threadid'], 'member_id' => $voter['memberid'], 'forum_id' => $row['forumid'], 'member_choices' => serialize(array(1 => $row['optionid'])));
$this->lib->convertPollVoter($voter['voteid'], $vsave);
}
//-----------------------------------------
// Options are stored in one place...
//-----------------------------------------
$choices = array();
$votes = array();
$totalVotes = 0;
ipsRegistry::DB('hb')->build(array('select' => '*', 'from' => 'polloptions', 'where' => "pollid='{$row['pollid']}'"));
$choiceRes = ipsRegistry::DB('hb')->execute();
while ($choice = ipsRegistry::DB('hb')->fetch($choiceRes)) {
$choices[$choice['optionid']] = $choice['description'];
$votes[$choice['optionid']] = $choice['votes'];
$totalVotes += $choice['votes'];
}
//-----------------------------------------
// Then we can do the actual poll
//-----------------------------------------
$poll_array = array(1 => array('question' => $row['threadsubject'], 'choice' => $choices, 'votes' => $votes));
$save = array('tid' => $row['threadid'], 'start_date' => strtotime($row['datecreated']), 'choices' => addslashes(serialize($poll_array)), 'starter_id' => $row['memberid'] == '-1' ? 0 : $row['memberid'], 'votes' => $totalVotes, 'forum_id' => $row['forumid'], 'poll_question' => $row['threadsubject']);
$this->lib->convertPoll($row['pollid'], $save);
}
$this->lib->next();
}
示例12: imprtFromXML
//.........这里部分代码省略.........
//-----------------------------------------
$xmlarchive->readXML($uploadedContent);
//-----------------------------------------
// Get the data
//-----------------------------------------
$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']}"));
示例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: tasksImportFromXML
/**
* Imports tasks from XML
*
* @param string $file Filename to import tasks from
* @param boolean $no_return Set to return true/false, instead of displaying results
* @return @e mixed True if $no_return is enabled, otherwise void
*/
public function tasksImportFromXML($file = '', $no_return = false)
{
/* INIT */
$file = $file ? $file : IPS_PUBLIC_PATH . 'resources/tasks.xml';
$inserted = 0;
$updated = 0;
$tasks = array();
/* Check to see if the file exists */
if (!is_file($file)) {
$this->registry->output->global_message = sprintf($this->lang->words['t_import404'], $file);
$this->taskManagerOverview();
return;
}
$content = @file_get_contents($file);
/* Grab current tasks */
$this->DB->build(array('select' => '*', 'from' => 'task_manager'));
$this->DB->execute();
while ($row = $this->DB->fetch()) {
$tasks[$row['task_key']] = $row;
}
/* Get the XML class */
require_once IPS_KERNEL_PATH . 'classXML.php';
/*noLibHook*/
$xml = new classXML(IPS_DOC_CHAR_SET);
$xml->loadXML($content);
/* Loop through the tasks */
foreach ($xml->fetchElements('row') as $record) {
$entry = $xml->fetchElementsFromRecord($record);
$_key = $entry['task_key'];
$entry['task_cronkey'] = $tasks[$_key]['task_cronkey'] ? $tasks[$_key]['task_cronkey'] : md5(uniqid(microtime()));
$entry['task_next_run'] = $tasks[$_key]['task_next_run'] ? $tasks[$_key]['task_next_run'] : time();
$entry['task_description'] = $entry['task_description'] ? $entry['task_description'] : '';
unset($entry['task_id']);
if ($tasks[$_key]['task_key']) {
unset($entry['task_cronkey']);
unset($entry['task_enabled']);
$updated++;
$this->DB->update('task_manager', $entry, "task_key='" . $tasks[$_key]['task_key'] . "'");
} else {
$inserted++;
$this->DB->insert('task_manager', $entry);
$tasks[$_key] = $entry;
}
}
/* Return or Bounce */
if ($no_return) {
$this->registry->output->global_message = sprintf($this->lang->words['t_inserted'], $inserted, $updated);
return TRUE;
} else {
$this->registry->output->global_message = sprintf($this->lang->words['t_inserted'], $inserted, $updated);
$this->taskManagerOverview();
}
}