本文整理汇总了PHP中vB_XML_Parser::parse方法的典型用法代码示例。如果您正苦于以下问题:PHP vB_XML_Parser::parse方法的具体用法?PHP vB_XML_Parser::parse怎么用?PHP vB_XML_Parser::parse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vB_XML_Parser
的用法示例。
在下文中一共展示了vB_XML_Parser::parse方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch_language
public static function fetch_language()
{
static $phrases;
if (!$phrases) {
require_once DIR . '/includes/class_xml.php';
$languagecode = defined('UPGRADE_LANGUAGE') ? UPGRADE_LANGUAGE : 'en';
$xmlobj = new vB_XML_Parser(false, DIR . '/install/upgrade_language_' . $languagecode . '.xml');
$xml = $xmlobj->parse(defined('UPGRADE_ENCODING') ? UPGRADE_ENCODING : 'ISO-8859-1');
foreach ($xml['group'] as $value) {
if (is_array($value['group'])) {
// step phrases
foreach ($value['group'] as $value2) {
if (!$value2['phrase'][0]) {
$value2['phrase'] = array($value2['phrase']);
}
foreach ($value2['phrase'] as $value3) {
$step = $value3['step'] ? "_{$value3['step']}" : '';
$phrases[$value['name']][$value2['name']][$value3['name'] . $step] = $value3['value'];
}
}
} else {
if (!$value['phrase'][0]) {
$value['phrase'] = array($value['phrase']);
}
foreach ($value['phrase'] as $value2) {
$step = $value2['step'] ? "_{$value2['step']}" : '';
$phrases[$value['name']][$value2['name'] . $step] = $value2['value'];
}
}
}
$GLOBALS['vbphrase'] =& $phrases['vbphrase'];
}
return $phrases;
}
示例2: fetch_podcast_categoryarray
/**
* Fetch array of podcast categories
*
* @return array Array of categories
*/
function fetch_podcast_categoryarray($categoryid)
{
require_once DIR . '/includes/class_xml.php';
$xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/podcast_vbulletin.xml');
$podcastdata = $xmlobj->parse();
$key = 1;
$output = array();
if (is_array($podcastdata['category'])) {
foreach ($podcastdata['category'] as $cats) {
if ($key == $categoryid) {
$output[] = htmlspecialchars_uni($cats['name']);
break;
}
$key++;
if (is_array($cats['sub']['name'])) {
foreach ($cats['sub']['name'] as $subcats) {
if ($key == $categoryid) {
$output[] = htmlspecialchars_uni($cats['name']);
$output[] = htmlspecialchars_uni($subcats);
break 2;
}
$key++;
}
}
}
}
return $output;
}
示例3: build_bbcode_video
function build_bbcode_video($checktable = false)
{
global $vbulletin;
if ($checktable) {
$vbulletin->db->hide_errors();
$vbulletin->db->query_write("SELECT url FROM " . TABLE_PREFIX . "bbcode_video LIMIT 1");
$vbulletin->db->show_errors();
if ($vbulletin->db->errno()) {
return;
}
}
require_once DIR . '/includes/class_xml.php';
$xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/bbcode_video_vbulletin.xml');
$data = $xmlobj->parse();
if (is_array($data['provider'])) {
$insert = array();
foreach ($data['provider'] as $provider) {
$items = array();
$items['tagoption'] = "'" . $vbulletin->db->escape_string($provider['tagoption']) . "'";
$items['provider'] = "'" . $vbulletin->db->escape_string($provider['title']) . "'";
$items['url'] = "'" . $vbulletin->db->escape_string($provider['url']) . "'";
$items['regex_url'] = "'" . $vbulletin->db->escape_string($provider['regex_url']) . "'";
$items['regex_scrape'] = "'" . $vbulletin->db->escape_string($provider['regex_scrape']) . "'";
$items['embed'] = "'" . $vbulletin->db->escape_string($provider['embed']) . "'";
$insert[] = implode(", ", $items);
}
if (!empty($insert)) {
$vbulletin->db->query_write("TRUNCATE TABLE " . TABLE_PREFIX . "bbcode_video");
$vbulletin->db->query_write("\n\t\t\t\tINSERT INTO " . TABLE_PREFIX . "bbcode_video\n\t\t\t\t\t(tagoption, provider, url, regex_url, regex_scrape, embed)\n\t\t\t\tVALUES\n\t\t\t\t\t(" . implode("), (", $insert) . ")\n\t\t\t");
}
}
$firsttag = '<vb:if condition="$provider == \'%1$s\'">';
$secondtag = '<vb:elseif condition="$provider == \'%1$s\'" />';
$template = array();
$bbcodes = $vbulletin->db->query_read("\n\t\tSELECT\n\t\t\ttagoption, embed\n\t\tFROM " . TABLE_PREFIX . "bbcode_video\n\t\tORDER BY priority\n\t");
while ($bbcode = $vbulletin->db->fetch_array($bbcodes)) {
if (empty($template)) {
$template[] = sprintf($firsttag, $bbcode['tagoption']);
} else {
$template[] = sprintf($secondtag, $bbcode['tagoption']);
}
$template[] = $bbcode['embed'];
}
$template[] = "</vb:if>";
$final = implode("\r\n", $template);
$vbulletin->db->query_write("\n\t\tDELETE FROM " . TABLE_PREFIX . "template\n\t\tWHERE\n\t\t\ttitle = 'bbcode_video'\n\t\t\tAND\n\t\t\tproduct IN ('', 'vbulletin')\n\t\t\tAND\n\t\t\tstyleid = 0\n\t");
require_once DIR . '/includes/adminfunctions_template.php';
if ($exists = $vbulletin->db->query_first_slave("\n\t\tSELECT templateid\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE\n\t\t\ttitle = 'bbcode_video'\n\t\t\t\tAND\n\t\t\tproduct IN ('', 'vbulletin')\n\t\t\t\tAND\n\t\t\tstyleid = -1\n\t\t")) {
$vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template\n\t\t\tSET\n\t\t\t\ttemplate = '" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\ttemplate_un = '" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\tdateline = " . TIMENOW . ",\n\t\t\t\tusername = '" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\tversion = '" . $vbulletin->options['templateversion'] . "'\n\t\t\tWHERE\n\t\t\t\ttemplateid = {$exists['templateid']}\n\t\t");
} else {
$vbulletin->db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t(template, template_un, dateline, username, templatetype, styleid, title, product, version)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t'" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\t\t'" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t'" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t'template',\n\t\t\t\t\t'-1',\n\t\t\t\t\t'bbcode_video',\n\t\t\t\t\t'vbulletin',\n\t\t\t\t\t'" . $vbulletin->options['templateversion'] . "'\n\t\t\t\t)\n\t\t");
}
if ($exists = $vbulletin->db->query_first_slave("\n\t\tSELECT templateid\n\t\tFROM " . TABLE_PREFIX . "template\n\t\tWHERE\n\t\t\ttitle = 'bbcode_video'\n\t\t\t\tAND\n\t\t\tproduct IN ('', 'vbulletin')\n\t\t\t\tAND\n\t\t\tstyleid = -2\n\t\t")) {
$vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "template\n\t\t\tSET\n\t\t\t\ttemplate = '" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\ttemplate_un = '" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\tdateline = " . TIMENOW . ",\n\t\t\t\tusername = '" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\tversion = '" . $vbulletin->options['templateversion'] . "'\n\t\t\tWHERE\n\t\t\t\ttemplateid = {$exists['templateid']}\n\t\t");
} else {
$vbulletin->db->query_write("\n\t\t\tREPLACE INTO " . TABLE_PREFIX . "template\n\t\t\t\t(template, template_un, dateline, username, templatetype, styleid, title, product, version)\n\t\t\tVALUES\n\t\t\t\t(\n\t\t\t\t\t'" . $vbulletin->db->escape_string(compile_template($final)) . "',\n\t\t\t\t\t'" . $vbulletin->db->escape_string($final) . "',\n\t\t\t\t\t" . TIMENOW . ",\n\t\t\t\t\t'" . $vbulletin->db->escape_string($vbulletin->userinfo['username']) . "',\n\t\t\t\t\t'template',\n\t\t\t\t\t'-2',\n\t\t\t\t\t'bbcode_video',\n\t\t\t\t\t'vbulletin',\n\t\t\t\t\t'" . $vbulletin->options['templateversion'] . "'\n\t\t\t\t)\n\t\t");
}
}
示例4: build_bbcode_video
function build_bbcode_video($checktable = false)
{
if ($checktable) {
try {
vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT));
} catch (Exception $e) {
return false;
}
}
require_once DIR . '/includes/class_xml.php';
$xmlobj = new vB_XML_Parser(false, DIR . '/includes/xml/bbcode_video_vbulletin.xml');
$data = $xmlobj->parse();
if (is_array($data['provider'])) {
$insert = array();
foreach ($data['provider'] as $provider) {
$items = array();
$items['tagoption'] = $provider['tagoption'];
$items['provider'] = $provider['title'];
$items['url'] = $provider['url'];
$items['regex_url'] = $provider['regex_url'];
$items['regex_scrape'] = $provider['regex_scrape'];
$items['embed'] = $provider['embed'];
$insert[] = $items;
}
if (!empty($insert)) {
vB::getDbAssertor()->assertQuery('truncateTable', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_METHOD, 'table' => 'bbcode_video'));
vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_MULTIPLEINSERT, vB_dB_Query::FIELDS_KEY => array('tagoption', 'provider', 'url', 'regex_url', 'regex_scrape', 'embed'), vB_dB_Query::VALUES_KEY => $insert));
}
}
$firsttag = '<vb:if condition="$provider == \'%1$s\'">';
$secondtag = '<vb:elseif condition="$provider == \'%1$s\'" />';
$template = array();
$bbcodes = vB::getDbAssertor()->assertQuery('bbcode_video', array(vB_dB_Query::TYPE_KEY => vB_dB_Query::QUERY_SELECT), array('field' => array('priority'), 'direction' => array(vB_dB_Query::SORT_ASC)));
foreach ($bbcodes as $bbcode) {
if (empty($template)) {
$template[] = sprintf($firsttag, $bbcode['tagoption']);
} else {
$template[] = sprintf($secondtag, $bbcode['tagoption']);
}
$template[] = $bbcode['embed'];
}
$template[] = "</vb:if>";
$final = implode("\r\n", $template);
$exists = vB::getDbAssertor()->getRow('template', array(vB_dB_Query::CONDITIONS_KEY => array(array('field' => 'title', 'value' => 'bbcode_video', 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'product', 'value' => array('', 'vbulletin'), 'operator' => vB_dB_Query::OPERATOR_EQ), array('field' => 'styleid', 'value' => -1, 'operator' => vB_dB_Query::OPERATOR_EQ))));
if ($exists) {
try {
vB_Api::instanceInternal('template')->update($exists['templateid'], 'bbcode_video', $final, 'vbulletin', false, false, '');
} catch (Exception $e) {
return false;
}
} else {
vB_Api::instanceInternal('template')->insert(-1, 'bbcode_video', $final, 'vbulletin');
}
return true;
}
示例5: getXmlHooks
public function getXmlHooks()
{
if (!$this->hasPermission()) {
return false;
}
$typelist = array();
$hooklocations = array();
require_once DIR . '/includes/class_xml.php';
$types = $this->assertor->getRows('getHooktypePhrases');
$hookfiles = vB_Api_Product::loadProductXmlList('hooks');
foreach ($types as $type) {
$typelist[] = $type['varname'];
}
$vbphrase = vB_Api::instanceInternal('phrase')->fetch($typelist);
foreach ($hookfiles as $file) {
if (!preg_match('#hooks_(.*).xml$#i', $file, $matches)) {
continue;
}
$product = $matches[1];
$phrased_product = $products[$product ? $product : 'vbulletin'];
if (!$phrased_product) {
$phrased_product = $product;
}
$xmlobj = new vB_XML_Parser(false, $location . $file);
$xml = $xmlobj->parse();
if (!is_array($xml['hooktype'][0])) {
$xml['hooktype'] = array($xml['hooktype']);
}
foreach ($xml['hooktype'] as $key => $hooks) {
if (!is_numeric($key)) {
continue;
}
$phrased_type = isset($vbphrase["hooktype_{$hooks['type']}"]) ? $vbphrase["hooktype_{$hooks['type']}"] : $hooks['type'];
$hooktype = $phrased_type;
$hooklocations["#{$hooktype}#"] = $hooktype;
if (!is_array($hooks['hook'])) {
$hooks['hook'] = array($hooks['hook']);
}
foreach ($hooks['hook'] as $hook) {
$hookid = trim(is_string($hook) ? $hook : $hook['value']);
if ($hookid !== '') {
$hooklocations[$hookid] = '--- ' . $hookid . ($product != 'vbulletin' ? " ({$phrased_product})" : '');
}
}
}
}
return $hooklocations;
}
示例6: parse
/**
* Parse XML
*
* @param string location of XML
*/
public function parse($xml)
{
print_dots_start('<b>' . $this->vbphrase['importing_product'] . "</b>, {$this->vbphrase[please_wait]}", ':', 'dspan');
$this->xmlobj = new vB_XML_Parser($xml);
if ($this->xmlobj->error_no == 1) {
print_dots_stop();
throw new vB_Exception_AdminStopMessage('no_xml_and_no_path');
}
if (!($this->productobj = $this->xmlobj->parse())) {
print_dots_stop();
throw new vB_Exception_AdminStopMessage(array('xml_error_x_at_line_y', $this->xmlobj->error_string(), $this->xmlobj->error_line()));
}
// ############## general product information
$this->productinfo['productid'] = substr(preg_replace('#[^a-z0-9_]#', '', strtolower($this->productobj['productid'])), 0, 25);
$this->productinfo['title'] = $this->productobj['title'];
$this->productinfo['description'] = $this->productobj['description'];
$this->productinfo['version'] = $this->productobj['version'];
$this->productinfo['active'] = $this->productobj['active'];
$this->productinfo['url'] = $this->productobj['url'];
$this->productinfo['versioncheckurl'] = $this->productobj['versioncheckurl'];
if (!$this->productinfo['productid']) {
print_dots_stop();
if (!empty($this->productobj['plugin'])) {
throw new vB_Exception_AdminStopMessage('this_file_appears_to_be_a_plugin');
} else {
throw new vB_Exception_AdminStopMessage('invalid_file_specified');
}
}
if (strtolower($this->productinfo['productid']) == 'vbulletin') {
print_dots_stop();
throw new vB_Exception_AdminStopMessage(array('product_x_installed_no_overwrite', 'vBulletin'));
}
// check for bitfield conflicts on install
$bitfields = vB_Bitfield_Builder::return_data();
if (!$bitfields) {
$bfobj =& vB_Bitfield_Builder::init();
if ($bfobj->errors) {
print_dots_stop();
throw new vB_Exception_AdminStopMessage(array('bitfield_conflicts_x', '<li>' . implode('</li><li>', $bfobj->errors) . '</li>'));
}
}
return true;
}
示例7: __construct
protected function __construct()
{
//We need the usergroups and the permission bitmaps.
$usergroups = vB_Api::instanceInternal('usergroup')->fetchUsergroupList($flushcache = false);
foreach ($usergroups as $usergroup) {
self::$usergroups[$usergroup['usergroupid']] = $usergroup['title'];
}
$this->permSettings = array('forumpermissions' => array(), 'forumpermissions2' => array(), 'moderatorpermissions' => array(), 'createpermissions' => array());
$parser = new vB_XML_Parser(false, DIR . '/includes/xml/bitfield_vbulletin.xml');
$bitfields = $parser->parse();
foreach ($bitfields['bitfielddefs']['group'] as $topGroup) {
if ($topGroup['name'] == 'ugp' or $topGroup['name'] == 'misc') {
foreach ($topGroup['group'] as $group) {
switch ($group['name']) {
case 'forumpermissions':
case 'forumpermissions2':
case 'moderatorpermissions':
foreach ($group['bitfield'] as $fielddef) {
if (!empty($fielddef['intperm'])) {
continue;
}
if (in_array($fielddef['name'], self::$bitfieldsUsed[$group['name']])) {
$fielddef['used'] = 1;
} else {
$fielddef['used'] = 0;
}
$this->permSettings[$group['name']][$fielddef['name']] = $fielddef;
}
break;
case 'createpermissions':
foreach ($group['bitfield'] as $fielddef) {
$fielddef['used'] = 1;
$this->permSettings[$group['name']][$fielddef['name']] = $fielddef;
}
break;
}
}
}
}
}
示例8: xml_import_style
/**
* Reads XML style file and imports data from it into the database
*
* @param string XML data
* @param integer Style ID
* @param integer Parent style ID
* @param string New style title
* @param boolean Allow vBulletin version mismatch
* @param integer Display order for new style
* @param boolean Allow user selection of new style
* @param int|null Starting template group index for this run of importing templates (0 based).
* Null means all templates (single run)
* @paream int|null
*
* @return array Array of information about the imported style
*/
function xml_import_style(
$xml = false,
$styleid = -1,
$parentid = -1,
$title = '',
$anyversion = false,
$displayorder = 1,
$userselect = true,
$startat = null,
$perpage = null
)
{
// $GLOBALS['path'] needs to be passed into this function or reference $vbulletin->GPC['path']
global $vbulletin, $vbphrase;
print_dots_start('<b>' . $vbphrase['importing_style'] . "</b>, $vbphrase[please_wait]", ':', 'dspan');
require_once(DIR . '/includes/class_xml.php');
//where is this used? I hate having this random global value in the middle of this function
$xmlobj = new vB_XML_Parser($xml, $vbulletin->GPC['path']);
if ($xmlobj->error_no == 1)
{
print_dots_stop();
print_stop_message('no_xml_and_no_path');
}
else if ($xmlobj->error_no == 2)
{
print_dots_stop();
print_stop_message('please_ensure_x_file_is_located_at_y', 'vbulletin-style.xml', $vbulletin->GPC['path']);
}
if(!$parsed_xml = $xmlobj->parse())
{
print_dots_stop();
print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line());
}
$version = $parsed_xml['vbversion'];
$master = ($parsed_xml['type'] == 'master' ? 1 : 0);
$title = (empty($title) ? $parsed_xml['name'] : $title);
$product = (empty($parsed_xml['product']) ? 'vbulletin' : $parsed_xml['product']);
$one_pass = (is_null($startat) AND is_null($perpage));
if (!$one_pass AND (!is_numeric($startat) OR !is_numeric($perpage) OR $perpage <= 0 OR $startat < 0))
{
print_dots_stop();
print_stop_message('');
}
if ($one_pass OR ($startat == 0))
{
// version check
$full_product_info = fetch_product_list(true);
$product_info = $full_product_info["$product"];
if ($version != $product_info['version'] AND !$anyversion AND !$master)
{
print_dots_stop();
print_stop_message('upload_file_created_with_different_version', $product_info['version'], $version);
}
//Initialize the style -- either init the master, create a new style, or verify the style to overwrite.
if ($master)
{
$import_data = @unserialize(fetch_adminutil_text('master_style_import'));
if (!empty($import_data) AND (TIMENOW - $import_data['last_import']) <= 30)
{
print_dots_stop();
print_stop_message('must_wait_x_seconds_master_style_import', vb_number_format($import_data['last_import'] + 30 - TIMENOW));
}
// overwrite master style
echo "<h3>$vbphrase[master_style]</h3>\n<p>$vbphrase[please_wait]</p>";
vbflush();
$vbulletin->db->query_write("
DELETE FROM " . TABLE_PREFIX . "template
WHERE styleid = -10 AND (product = '" . $vbulletin->db->escape_string($product) . "'" .
iif($product == 'vbulletin', " OR product = ''") . ")"
);
//.........这里部分代码省略.........
示例9: fetch
/**
* Returns array of the XML data parsed into array format
*
* @param string file Filename
* @param boolean Process disabled products?
*
* @return array
*/
function fetch($file, $layout, $include_disabled = false)
{
global $vbulletin;
$obj =& vB_Bitfield_Builder::init();
$xmlobj = new vB_XML_Parser(false, $file);
if (!($xml = $xmlobj->parse())) {
// xml parser failed
return false;
}
if (!$include_disabled and $xml['product'] and $xml['product'] != 'vbulletin' and empty($vbulletin->products["{$xml['product']}"])) {
// This product is disabled
return false;
}
$tempdata = array();
if (!$layout) {
$xmlignore = $xml['ignoregroups'];
}
$xml = $xml['bitfielddefs'];
if (!isset($xml['group'][0])) {
$xml['group'] = array($xml['group']);
}
foreach ($xml['group'] as $bitgroup) {
if (!isset($tempdata["{$bitgroup['name']}"])) {
// this file as a group with the same name so don't intialise it
$tempdata["{$bitgroup['name']}"] = array();
}
// deal with actual bitfields
if (!isset($bitgroup['group'])) {
$tempdata["{$bitgroup['name']}"] = $obj->bitfield_array_convert($bitgroup['bitfield'], $layout);
} else {
$subdata = array();
if (!isset($bitgroup['group'][0])) {
$bitgroup['group'] = array($bitgroup['group']);
}
foreach ($bitgroup['group'] as $subgroup) {
$subdata["{$subgroup['name']}"] = $obj->bitfield_array_convert($subgroup['bitfield'], $layout);
}
$tempdata["{$bitgroup['name']}"] = $subdata;
}
}
if (!$layout and !empty($xmlignore['group'])) {
if (!isset($xmlignore['group'][0])) {
$xmlignore['group'] = array($xmlignore['group']);
}
foreach ($xmlignore['group'] as $title => $moo) {
if (!empty($moo['ignoregroups'])) {
$moo['layoutperm']['ignoregroups'] = $moo['ignoregroups'];
}
$tempdata['layout']["{$moo['name']}"] = $moo['layoutperm'];
}
}
$xmlobj = null;
return $tempdata;
}
示例10: get_svn_data
public function get_svn_data($template_filenames, $minsvnversion = 1, $skip_revisions = array())
{
$template_dir = $this->get_svn_template_source();
// pull data from cache, to reduce what has to be retrieved from the svn server
if ($cache = $this->get_svn_data_from_cache($template_dir)) {
$data = $cache['data'];
$minsvnversion = $cache['minsvnversion'];
unset($cache);
}
$cmd = 'svn log -rHEAD:' . $minsvnversion . ' --xml -v "' . $template_dir . '"';
$text = shell_exec($cmd);
$xmlobj = new vB_XML_Parser($text);
$parsed_xml = $xmlobj->parse();
if ($parsed_xml === false) {
$this->errors[] = sprintf("xml error '%s', on line '%d'", $xmlobj->error_string(), $xmlobj->error_line());
return false;
}
if (!is_array($parsed_xml)) {
// There are no log entries within the <log> tags. It's just \r\n.
return false;
}
$logentries = $this->get_xml_list($parsed_xml['logentry']);
$template_dir_basename = basename($template_dir);
// highest revision number for cache
$max_revision = 1;
$update_count = 0;
foreach ($logentries as $logentry) {
if (in_array($logentry['revision'], $skip_revisions)) {
continue;
}
// highest revision number for cache
$max_revision = max($max_revision, $logentry['revision']);
$paths = $this->get_xml_list($logentry['paths']['path']);
foreach ($paths as $path) {
$is_mod = $path['action'] == 'M';
$is_rename = (($path['action'] == 'R' or $path['action'] == 'A') and $path['copyfrom-path']);
if ($is_mod or $is_rename) {
//make sure that the paths are the same one directory level up. This should cut down
//dramatically on the potential for false matches since both paths would have to end in
//templates/templatename.ext. This isn't perfect, but reduces the change of conflict
//to a level where it realistically won't happen. We can't easily match the paths because
//we don't really know how far up we should be checking. If there is a conflict the
//only consequence is that we advance the change date in the xml unnecesarily.
if (basename(dirname($path['value'])) == $template_dir_basename) {
$path_file = basename($path['value']);
$is_template = in_array($path_file, $template_filenames, true);
$last_updated = strtotime($logentry['date']);
$not_cached = !isset($data[$path_file]['lastupdated']);
$is_newer = (isset($data[$path_file]['lastupdated']) and $data[$path_file]['lastupdated'] < $last_updated);
//if(!array_key_exists($path_file, $data) AND in_array($path_file, $template_filenames))
if ($is_template and ($not_cached or $is_newer)) {
$data[$path_file] = array('lastupdated' => $last_updated, 'username' => $logentry['author']);
++$update_count;
}
}
}
}
}
ksort($data);
// cache data and highest revision number
$this->save_svn_data_to_cache($template_dir, $data, $max_revision, $update_count);
return $data;
}
示例11: parseFile
public static function parseFile($filepath)
{
$xmlobj = new vB_XML_Parser(false, $filepath);
if ($xmlobj->error_no() == 1 or $xmlobj->error_no() == 2) {
throw new Exception("Please ensure that the file {$filepath} exists");
}
if (!($parsed_xml = $xmlobj->parse())) {
throw new Exception('xml error ' . $xmlobj->error_string() . ', on line ' . $xmlobj->error_line());
}
return $parsed_xml;
}
示例12: xml_import_language
/**
* Imports a language from a language XML file
*
* @param string XML language string
* @param integer Language to overwrite
* @param string Override title for imported language
* @param boolean Allow import of language from mismatched vBulletin version
* @param boolean Allow user-select of imported language
* @param boolean Echo output..
* @param boolean Read charset from XML header
*/
function xml_import_language($xml = false, $languageid = -1, $title = '', $anyversion = false, $userselect = true, $output = true, $readcharset = false)
{
global $vbulletin, $vbphrase;
print_dots_start('<b>' . $vbphrase['importing_language'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan');
require_once DIR . '/includes/class_xml.php';
require_once DIR . '/includes/functions_misc.php';
$xmlobj = new vB_XML_Parser($xml, $GLOBALS['path'], $readcharset);
if ($xmlobj->error_no == 1) {
print_dots_stop();
print_stop_message('no_xml_and_no_path');
} else {
if ($xmlobj->error_no == 2) {
print_dots_stop();
print_stop_message('please_ensure_x_file_is_located_at_y', 'vbulletin-language.xml', $GLOBALS['path']);
}
}
if (!($arr =& $xmlobj->parse())) {
print_dots_stop();
print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line());
}
if (!$arr['phrasetype']) {
print_dots_stop();
print_stop_message('invalid_file_specified');
}
$title = empty($title) ? $arr['name'] : $title;
$version = $arr['vbversion'];
$master = $arr['type'] == 'master' ? 1 : 0;
$just_phrases = $arr['type'] == 'phrases' ? 1 : 0;
if (!empty($arr['settings'])) {
$langinfo = $arr['settings'];
}
$langinfo['product'] = empty($arr['product']) ? 'vbulletin' : $arr['product'];
// look for skipped groups
$skipped_groups = array();
if (!empty($arr['skippedgroups'])) {
$skippedgroups =& $arr['skippedgroups']['skippedgroup'];
if (!is_array($skippedgroups[0])) {
$skippedgroups = array($skippedgroups);
}
foreach ($skippedgroups as $skipped) {
if (is_array($skipped)) {
$skipped_groups[] = $vbulletin->db->escape_string($skipped['value']);
} else {
$skipped_groups[] = $vbulletin->db->escape_string($skipped);
}
}
}
if ($skipped_groups) {
$sql_skipped = "AND " . TABLE_PREFIX . "phrase.fieldname NOT IN ('" . implode("', '", $skipped_groups) . "')";
} else {
$sql_skipped = '';
}
foreach ($langinfo as $key => $val) {
$langinfo["{$key}"] = $vbulletin->db->escape_string(trim($val));
}
$langinfo['options'] = intval($langinfo['options']);
if ($version != $vbulletin->options['templateversion'] and !$anyversion and !$master) {
print_dots_stop();
print_stop_message('upload_file_created_with_different_version', $vbulletin->options['templateversion'], $version);
}
//set up the phrase array
$arr = $arr['phrasetype'];
if (!is_array($arr[0])) {
$arr = array($arr);
}
//spin through the phrases to check validity. We want to do this *before* we prep for import
//so that if we abort do to an error, we haven't made any changes first
foreach (array_keys($arr) as $key) {
$phraseTypes =& $arr["{$key}"];
foreach ($phraseTypes['phrase'] as $phrase) {
if (!validate_string_for_interpolation($phrase['value'])) {
print_dots_stop();
print_stop_message('phrase_text_not_safe', $phrase['name']);
}
}
}
// prepare for import
if ($master) {
// lets stop it from dieing cause someone borked a previous update
$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "phrase WHERE languageid = -10");
// master style
if ($output and VB_AREA != 'Install' and VB_AREA != 'Upgrade') {
echo "<h3>{$vbphrase['master_language']}</h3>\n<p>{$vbphrase['please_wait']}</p>";
vbflush();
}
$vbulletin->db->query_write("\n\t\t\tUPDATE " . TABLE_PREFIX . "phrase SET\n\t\t\t\tlanguageid = -10\n\t\t\tWHERE languageid = -1\n\t\t\t\tAND (product = '" . $vbulletin->db->escape_string($langinfo['product']) . "'" . iif($langinfo['product'] == 'vbulletin', " OR product = ''") . ")\n\t\t\t\t{$sql_skipped}\n\t\t");
$languageid = -1;
} else {
if ($languageid == 0) {
//.........这里部分代码省略.........
示例13: array
if ($_REQUEST['do'] == 'edit' or $_REQUEST['do'] == 'add') {
$products = fetch_product_list();
$hooklocations = array();
require_once DIR . '/includes/class_xml.php';
$handle = opendir(DIR . '/includes/xml/');
while (($file = readdir($handle)) !== false) {
if (!preg_match('#^hooks_(.*).xml$#i', $file, $matches)) {
continue;
}
$product = $matches[1];
$phrased_product = $products[$product ? $product : 'vbulletin'];
if (!$phrased_product) {
$phrased_product = $product;
}
$xmlobj = new vB_XML_Parser(false, DIR . "/includes/xml/{$file}");
$xml = $xmlobj->parse();
if (!is_array($xml['hooktype'][0])) {
// ugly kludge but it works...
$xml['hooktype'] = array($xml['hooktype']);
}
foreach ($xml['hooktype'] as $key => $hooks) {
if (!is_numeric($key)) {
continue;
}
$phrased_type = isset($vbphrase["hooktype_{$hooks['type']}"]) ? $vbphrase["hooktype_{$hooks['type']}"] : $hooks['type'];
$hooktype = $phrased_product . ' : ' . $phrased_type;
if (!is_array($hooks['hook'])) {
$hooks['hook'] = array($hooks['hook']);
}
foreach ($hooks['hook'] as $hook) {
$hookid = trim(is_string($hook) ? $hook : $hook['value']);
示例14: xml_import_style
/**
* Reads XML style file and imports data from it into the database
*
* @param string XML data
* @param integer Style ID
* @param integer Parent style ID
* @param string New style title
* @param boolean Allow vBulletin version mismatch
* @param integer Display order for new style
* @param boolean Allow user selection of new style
*/
function xml_import_style($xml = false, $styleid = -1, $parentid = -1, $title = '', $anyversion = false, $displayorder = 1, $userselect = true)
{
// $GLOBALS['path'] needs to be passed into this function or reference $vbulletin->GPC['path']
global $vbulletin, $vbphrase;
print_dots_start('<b>' . $vbphrase['importing_style'] . "</b>, {$vbphrase['please_wait']}", ':', 'dspan');
require_once DIR . '/includes/class_xml.php';
$xmlobj = new vB_XML_Parser($xml, $vbulletin->GPC['path']);
if ($xmlobj->error_no == 1) {
print_dots_stop();
print_stop_message('no_xml_and_no_path');
} else {
if ($xmlobj->error_no == 2) {
print_dots_stop();
print_stop_message('please_ensure_x_file_is_located_at_y', 'vbulletin-style.xml', $vbulletin->GPC['path']);
}
}
if (!($arr = $xmlobj->parse())) {
print_dots_stop();
print_stop_message('xml_error_x_at_line_y', $xmlobj->error_string(), $xmlobj->error_line());
}
if (!$arr['templategroup']) {
print_dots_stop();
print_stop_message('invalid_file_specified');
}
$version = $arr['vbversion'];
$master = $arr['type'] == 'master' ? 1 : 0;
$title = empty($title) ? $arr['name'] : $title;
$product = empty($arr['product']) ? 'vbulletin' : $arr['product'];
$arr = $arr['templategroup'];
if (empty($arr[0])) {
$arr = array($arr);
}
$full_product_info = fetch_product_list(true);
$product_info = $full_product_info["{$product}"];
// version check
if ($version != $product_info['version'] and !$anyversion and !$master) {
print_dots_stop();
print_stop_message('upload_file_created_with_different_version', $product_info['version'], $version);
}
if ($master) {
// overwrite master style
echo "<h3>{$vbphrase['master_style']}</h3>\n<p>{$vbphrase['please_wait']}</p>";
vbflush();
$vbulletin->db->query_write("DELETE FROM " . TABLE_PREFIX . "template WHERE styleid = -10 AND (product = '" . $vbulletin->db->escape_string($product) . "'" . iif($product == 'vbulletin', " OR product = ''") . ")");
$vbulletin->db->query_write("UPDATE " . TABLE_PREFIX . "template SET styleid = -10 WHERE styleid = -1 AND (product = '" . $vbulletin->db->escape_string($product) . "'" . iif($product == 'vbulletin', " OR product = ''") . ")");
$styleid = -1;
} else {
if ($styleid == -1) {
// creating a new style
if ($test = $vbulletin->db->query_first("SELECT styleid FROM " . TABLE_PREFIX . "style WHERE title = '" . $vbulletin->db->escape_string($title) . "'")) {
print_dots_stop();
print_stop_message('style_already_exists', $title);
} else {
echo "<h3><b>" . construct_phrase($vbphrase['creating_a_new_style_called_x'], $title) . "</b></h3>\n<p>{$vbphrase['please_wait']}</p>";
vbflush();
/*insert query*/
$styleresult = $vbulletin->db->query_write("\n\t\t\t\t\tINSERT INTO " . TABLE_PREFIX . "style\n\t\t\t\t\t(title, parentid, displayorder, userselect)\n\t\t\t\t\tVALUES\n\t\t\t\t\t('" . $vbulletin->db->escape_string($title) . "', {$parentid}, {$displayorder}, " . ($userselect ? 1 : 0) . ")\n\t\t\t\t");
$styleid = $vbulletin->db->insert_id($styleresult);
}
} else {
// overwriting an existing style
if ($getstyle = $vbulletin->db->query_first("SELECT title FROM " . TABLE_PREFIX . "style WHERE styleid = {$styleid}")) {
echo "<h3><b>" . construct_phrase($vbphrase['overwriting_style_x'], $getstyle['title']) . "</b></h3>\n<p>{$vbphrase['please_wait']}</p>";
vbflush();
} else {
print_dots_stop();
print_stop_message('cant_overwrite_non_existent_style');
}
}
}
// types array...
$types = array($vbphrase['template'], $vbphrase['stylevar'], $vbphrase['css'], $vbphrase['replacement_variable']);
$querybits = array();
$querytemplates = 0;
foreach ($arr as $templategroup) {
if (empty($templategroup['template'][0])) {
$tg = array($templategroup['template']);
} else {
$tg =& $templategroup['template'];
}
foreach ($tg as $template) {
$title = $vbulletin->db->escape_string($template['name']);
$template['template'] = $vbulletin->db->escape_string($template['value']);
$template['username'] = $vbulletin->db->escape_string($template['username']);
if ($template['templatetype'] != 'template') {
// template is a special template
$querybits[] = "({$styleid}, '{$template['templatetype']}', '{$title}', '{$template['template']}', '', {$template['date']}, '{$template['username']}', '" . $vbulletin->db->escape_string($template['version']) . "', '" . $vbulletin->db->escape_string($product) . "')";
} else {
// template is a standard template
//.........这里部分代码省略.........
示例15: loadProductXmlListParsed
public static function loadProductXmlListParsed($type = '', $typekey = false)
{
$list = self::loadProductXmlList($type, $typekey);
foreach ($list as $product => $file) {
$xmlobj = new vB_XML_Parser(false, $file);
$data = $xmlobj->parse();
$list[$product] = $data;
}
return $list;
}