本文整理汇总了PHP中XenForo_Helper_DevelopmentXml::fixPhpBug50670方法的典型用法代码示例。如果您正苦于以下问题:PHP XenForo_Helper_DevelopmentXml::fixPhpBug50670方法的具体用法?PHP XenForo_Helper_DevelopmentXml::fixPhpBug50670怎么用?PHP XenForo_Helper_DevelopmentXml::fixPhpBug50670使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XenForo_Helper_DevelopmentXml
的用法示例。
在下文中一共展示了XenForo_Helper_DevelopmentXml::fixPhpBug50670方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: importSmiliesXml
/**
* Imports a smilie XML file.
*
* @param SimpleXMLElement $document
* @param string $smilieGroupId
* @param integer $overwriteSmilieId
*
* @return array List of cache rebuilders to run
*/
public function importSmiliesXml(SimpleXMLElement $document, $overwrite = 0)
{
if ($document->getName() != 'smilies') {
throw new XenForo_Exception(new XenForo_Phrase('waindigo_provided_file_is_not_valid_smilie_xml_smilieimporter'), true);
}
$smilies = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->smilie);
$db = $this->_getDb();
/* @var $smilie SimpleXMLElement */
XenForo_Db::beginTransaction($db);
foreach ($smilies as $smilie) {
$smilieText = XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->smilie_text);
$existing = $this->getSmiliesByText($smilieText);
$updateText = array();
foreach ($existing as $text => $existingSmilie) {
if ($overwrite) {
if (isset($updateText[$existingSmilie['smilie_id']])) {
$existingSmilie['smilie_text'] = $updateText[$existingSmilie['smilie_id']];
}
$existingSmilie['smilie_text'] = preg_split('/\\R/m', $existingSmilie['smilie_text']);
unset($existingSmilie['smilie_text'][array_search($text, $existingSmilie['smilie_text'])]);
if (!empty($existingSmilie['smilie_text'])) {
$updateText[$existingSmilie['smilie_id']] = implode(PHP_EOL, $existingSmilie['smilie_text']);
} else {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
$dw->setExistingData($existingSmilie['smilie_id']);
$dw->delete();
}
} else {
$smilieText = preg_split('/\\R/m', $smilieText);
if (in_array($text, $smilieText)) {
unset($smilieText[array_search($text, $smilieText)]);
}
$smilieText = implode(PHP_EOL, $smilieText);
if (!trim($smilieText)) {
continue;
}
}
}
foreach ($updateText as $smilieId => $updateTextItem) {
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
$dw->setExistingData($smilieId);
$dw->set('smilie_text', $updateTextItem);
$dw->save();
}
if (!trim($smilieText)) {
continue;
}
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Smilie', XenForo_DataWriter::ERROR_SILENT);
$spriteParams = array('h' => (string) $smilie['h'], 'w' => (string) $smilie['w'], 'x' => (string) $smilie['x'], 'y' => (string) $smilie['y']);
$dw->bulkSet(array('title' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->title), 'image_url' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($smilie->image_url), 'smilie_text' => $smilieText, 'sprite_mode' => (string) $smilie['sprite_mode'], 'sprite_params' => $spriteParams));
$dw->save();
}
XenForo_Db::commit($db);
}
示例2: importListenersXml
public function importListenersXml(SimpleXMLElement $xml, $blockId)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$this->deleteListenersByBlock($blockId);
$listeners = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->listener);
foreach ($listeners as $event) {
$eventId = (string) $event['event_id'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_CodeEventListener');
$dw->setOption(XenForo_DataWriter_CodeEventListener::OPTION_REBUILD_CACHE, false);
$dw->bulkSet(array('event_id' => (string) $event['event_id'], 'execute_order' => (string) $event['execute_order'], 'callback_class' => (string) $event['callback_class'], 'callback_method' => (string) $event['callback_method'], 'active' => (string) $event['active'], 'description' => (string) $event['description']));
$dw->save();
}
$this->getModelFromCache('XenForo_Model_CodeEvent')->rebuildEventListenerCache();
XenForo_Db::commit($db);
return;
}
示例3: importPhrasesXml
public function importPhrasesXml(SimpleXMLElement $xml, $blockId)
{
$existingPhrases = $this->getPhrasesByBlock($blockId);
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$phrases = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->phrase);
foreach ($phrases as $phrase) {
$phraseName = (string) $phrase['title'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_Phrase');
if (isset($existingPhrases[$phraseName])) {
$dw->setExistingData($existingPhrases[$phraseName], true);
}
$dw->bulkSet(array('language_id' => '0', 'title' => $phraseName, 'phrase_text' => (string) $phrase));
$dw->save();
}
XenForo_Db::commit($db);
return;
}
示例4: importFromFile
public function importFromFile($fileName, $deleteAll = false)
{
if (!file_exists($fileName) || !is_readable($fileName)) {
throw new XenForo_Exception(new XenForo_Phrase('please_enter_valid_file_name_requested_file_not_read'), true);
}
try {
$document = new SimpleXMLElement($fileName, 0, true);
} catch (Exception $e) {
throw new XenForo_Exception(new XenForo_Phrase('provided_file_was_not_valid_xml_file'), true);
}
if ($document->getName() != 'widget_framework') {
throw new XenForo_Exception(new XenForo_Phrase('wf_provided_file_is_not_an_widgets_xml_file'), true);
}
$widgets = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->widget);
XenForo_Db::beginTransaction();
if ($deleteAll) {
// get global widgets from database and delete them all!
// NOTE: ignore widget page widgets
$existingWidgets = $this->getGlobalWidgets(false, false);
foreach ($existingWidgets as $existingWidget) {
$dw = XenForo_DataWriter::create('WidgetFramework_DataWriter_Widget');
$dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_SKIP_REBUILD, true);
$dw->setExistingData($existingWidget);
$dw->delete();
}
}
foreach ($widgets as $widget) {
$dw = XenForo_DataWriter::create('WidgetFramework_DataWriter_Widget');
$dw->setExtraData(WidgetFramework_DataWriter_Widget::EXTRA_DATA_SKIP_REBUILD, true);
$dw->set('title', $widget['title']);
$dw->set('class', $widget['class']);
$dw->set('position', $widget['position']);
$dw->set('display_order', $widget['display_order']);
$dw->set('active', intval($widget['active']));
$dw->set('options', unserialize(XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($widget->options)));
$dw->save();
}
$this->buildCache();
XenForo_Db::commit();
}
示例5: importBbCodeMediaSitesAddOnXml
/**
* Imports the BB code media sites for an add-on.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the event data
* @param string $addOnId Add-on to import for
*/
public function importBbCodeMediaSitesAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$db->delete('xf_bb_code_media_site', 'addon_id = ' . $db->quote($addOnId));
$xmlSites = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->site);
$siteIds = array();
foreach ($xmlSites as $site) {
$siteIds[] = (string) $site['media_site_id'];
}
$sites = $this->getBbCodeMediaSites(array('mediaSiteIds' => $siteIds));
foreach ($xmlSites as $site) {
$siteId = (string) $site['media_site_id'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_BbCodeMediaSite');
if (isset($sites[$siteId])) {
$dw->setExistingData($sites[$siteId]);
}
$dw->bulkSet(array('media_site_id' => $siteId, 'site_title' => (string) $site['site_title'], 'site_url' => (string) $site['site_url'], 'match_urls' => (string) XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($site->match_urls), 'match_is_regex' => (int) $site['match_is_regex'], 'match_callback_class' => (string) $site['match_callback_class'], 'match_callback_method' => (string) $site['match_callback_method'], 'embed_html' => (string) XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($site->embed_html), 'embed_html_callback_class' => (string) $site['embed_html_callback_class'], 'embed_html_callback_method' => (string) $site['embed_html_callback_method'], 'supported' => (int) $site['supported'], 'addon_id' => $addOnId));
$dw->save();
}
XenForo_Db::commit($db);
}
示例6: importPrefixesAddOnXml
/**
* Imports the add-on route prefixes XML.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the prefix data
* @param string $addOnId Add-on to import for
*/
public function importPrefixesAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
$currentPrefixes = $this->getAllPrefixesGroupedByRouteType();
XenForo_Db::beginTransaction($db);
$this->deletePrefixesForAddOn($addOnId);
$routeTypes = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->route_type);
foreach ($routeTypes as $typeXml) {
$type = (string) $typeXml['type'];
if (!$type) {
continue;
}
$conflictPrefixes = $this->getPrefixesByRouteType($type);
$types = XenForo_Helper_DevelopmentXml::fixPhpBug50670($typeXml->prefix);
foreach ($types as $prefix) {
$originalPrefixValue = (string) $prefix['original_prefix'];
$prefixInfo = array('route_type' => $type, 'route_class' => (string) $prefix['class'], 'original_prefix' => $originalPrefixValue, 'build_link' => (string) $prefix['build_link'], 'addon_id' => $addOnId);
$dw = XenForo_DataWriter::create('XenForo_DataWriter_RoutePrefix');
if (isset($conflictPrefixes[$originalPrefixValue])) {
$dw->setExistingData($conflictPrefixes[$originalPrefixValue], true);
}
$dw->setOption(XenForo_DataWriter_RoutePrefix::OPTION_REBUILD_CACHE, false);
$dw->bulkSet($prefixInfo);
$dw->save();
}
}
$this->rebuildRoutePrefixCache();
XenForo_Db::commit($db);
}
示例7: importAdminNavigationAddOnXml
/**
* Imports the add-on admin navigation XML.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the navigation data
* @param string $addOnId Add-on to import for
*/
public function importAdminNavigationAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$this->deleteAdminNavigationForAddOn($addOnId);
$xmlNav = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->navigation);
$navIds = array();
foreach ($xmlNav as $nav) {
$navIds[] = (string) $nav['navigation_id'];
}
$existingNavigation = $this->getAdminNavigationEntriesByIds($navIds);
foreach ($xmlNav as $nav) {
$navId = (string) $nav['navigation_id'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_AdminNavigation');
if (isset($existingNavigation[$navId])) {
$dw->setExistingData($existingNavigation[$navId], true);
}
$dw->bulkSet(array('navigation_id' => $navId, 'parent_navigation_id' => (string) $nav['parent_navigation_id'], 'display_order' => (string) $nav['display_order'], 'link' => (string) $nav['link'], 'admin_permission_id' => (string) $nav['admin_permission_id'], 'debug_only' => (string) $nav['debug_only'], 'hide_no_children' => (string) $nav['hide_no_children'], 'addon_id' => $addOnId));
$dw->save();
}
XenForo_Db::commit($db);
}
示例8: processCustomFields
public function processCustomFields(ThemeHouse_ObjectFields_Extend_ThemeHouse_Objects_DataWriter_Class $dw)
{
/* @var $document SimpleXMLElement */
$document = $this->_importDocument;
$customFields = XenForo_Helper_DevelopmentXml::fixPhpBug50670($document->custom_fields->custom_field);
$availableFields = array();
foreach ($customFields as $customField) {
if ($customField && $customField['field_id']) {
$availableFields[] = (string) $customField['field_id'];
}
}
$this->_getFieldModel()->updateObjectFieldClassAssociationByClass($dw->get('object_class_id'), $availableFields);
}
示例9: importOptionsAddOnXml
/**
* Imports the add-on admin navigation XML.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the navigation data
* @param string $addOnId Add-on to import for
*/
public function importOptionsAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
$options = $this->getAllOptions();
XenForo_Db::beginTransaction($db);
$this->deleteOptionsForAddOn($addOnId);
$xmlGroups = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->group);
$xmlOptions = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->option);
$groupIds = array();
foreach ($xmlGroups as $group) {
$groupIds[] = (string) $group['group_id'];
}
$optionIds = array();
foreach ($xmlOptions as $option) {
$optionIds[] = (string) $option['option_id'];
}
$existingGroups = $this->getOptionGroupsByIds($groupIds);
$existingOptions = $this->getOptionsByIds($optionIds);
foreach ($xmlGroups as $group) {
$groupId = (string) $group['group_id'];
$groupDw = XenForo_DataWriter::create('XenForo_DataWriter_OptionGroup');
if (isset($existingGroups[$groupId])) {
$groupDw->setExistingData($existingGroups[$groupId], true);
}
$groupDw->setOption(XenForo_DataWriter_Option::OPTION_REBUILD_CACHE, false);
$groupDw->bulkSet(array('group_id' => $groupId, 'display_order' => (string) $group['display_order'], 'debug_only' => (string) $group['debug_only'], 'addon_id' => $addOnId));
$groupDw->save();
}
foreach ($xmlOptions as $option) {
$optionId = (string) $option['option_id'];
$optionDw = XenForo_DataWriter::create('XenForo_DataWriter_Option');
if (isset($existingOptions[$optionId])) {
$optionDw->setExistingData($existingOptions[$optionId], true);
}
$optionDw->setOption(XenForo_DataWriter_Option::OPTION_REBUILD_CACHE, false);
$optionDw->bulkSet(array('option_id' => $optionId, 'edit_format' => (string) $option['edit_format'], 'data_type' => (string) $option['data_type'], 'can_backup' => (string) $option['can_backup'], 'addon_id' => $addOnId));
if ((string) $option['validation_class']) {
$optionDw->set('validation_class', (string) $option['validation_class']);
$optionDw->set('validation_method', (string) $option['validation_method']);
}
$optionDw->set('default_value', (string) $option->default_value);
$optionDw->set('edit_format_params', (string) $option->edit_format_params);
$optionDw->set('sub_options', (string) $option->sub_options);
$relations = array();
foreach ($option->relation as $relation) {
$relations[(string) $relation['group_id']] = (string) $relation['display_order'];
}
$optionDw->setRelations($relations);
if (isset($options[$optionDw->get('option_id')])) {
$optionDw->setOption(XenForo_DataWriter_Option::OPTION_VALIDATE_VALUE, false);
$optionDw->set('option_value', $options[$optionDw->get('option_id')]['option_value']);
}
$optionDw->save();
}
$this->rebuildOptionCache();
XenForo_Db::commit($db);
}
示例10: importPhrasesAddOnXml
/**
* Imports the master language (phrase) XML for the specified add-on.
*
* @param SimpleXMLElement $xml
* @param string $addOnId
* @param integer $maxExecution Maximum run time in seconds
* @param integer $offset Number of elements to skip
*
* @return boolean|integer True on completion; false if the XML isn't correct; integer otherwise with new offset value
*/
public function importPhrasesAddOnXml(SimpleXMLElement $xml, $addOnId, $maxExecution = 0, $offset = 0)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$startTime = microtime(true);
if ($offset == 0) {
$this->deletePhrasesForAddOn($addOnId);
}
$phrases = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->phrase);
$titles = array();
$current = 0;
foreach ($phrases as $phrase) {
$current++;
if ($current <= $offset) {
continue;
}
$titles[] = (string) $phrase['title'];
}
$existingPhrases = $this->getPhrasesInLanguageByTitles($titles, 0);
if ($maxExecution) {
// take off whatever we've used
$maxExecution -= microtime(true) - $startTime;
}
$return = $this->importPhrasesXml($xml, 0, $addOnId, $existingPhrases, $maxExecution, $offset);
XenForo_Db::commit($db);
return $return;
}
示例11: importFieldsAddOnXml
/**
* Imports the add-on fields XML.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the data
* @param string $addOnId Add-on to import for
* @param integer $maxExecution Maximum run time in seconds
* @param integer $offset Number of elements to skip
*
* @return boolean integer on completion; false if the XML isn't correct;
* integer otherwise with new offset value
*/
public function importFieldsAddOnXml(SimpleXMLElement $xml, $addOnId, $maxExecution = 0, $offset = 0)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$startTime = microtime(true);
$fields = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->field);
$current = 0;
$restartOffset = false;
foreach ($fields as $field) {
$current++;
if ($current <= $offset) {
continue;
}
$fieldId = (string) $field['field_id'];
if (!$field['addon_id']) {
$field->addAttribute('addon_id', $addOnId);
}
$this->importFieldXml($field, 0, $fieldId);
if ($maxExecution && microtime(true) - $startTime > $maxExecution) {
$restartOffset = $current;
break;
}
}
XenForo_Db::commit($db);
return $restartOffset ? $restartOffset : true;
}
示例12: importPermissionsAddOnXml
/**
* Imports the add-on permissions XML.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the navigation data
* @param string $addOnId Add-on to import for
*/
public function importPermissionsAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$this->deletePermissionsForAddOn($addOnId);
$groups = $xml->permission_groups ? XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->permission_groups->permission_group) : array();
$permissions = $xml->permissions ? XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->permissions->permission) : array();
$interfaceGroups = $xml->interface_groups ? XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->interface_groups->interface_group) : array();
$permissionGroupIds = array();
foreach ($groups as $group) {
$permissionGroupIds[] = (string) $group['permission_group_id'];
}
$permissionIdPairs = array();
foreach ($permissions as $permission) {
$permissionIdPairs[] = array((string) $permission['permission_group_id'], (string) $permission['permission_id']);
}
$interfaceGroupIds = array();
foreach ($interfaceGroups as $group) {
$interfaceGroupIds[] = (string) $group['interface_group_id'];
}
$existingGroups = $this->getPermissionGroupsByIds($permissionGroupIds);
$existingPermissions = $this->getPermissionsByPairs($permissionIdPairs);
$existingInterfaceGroups = $this->getPermissionInterfaceGroupsByIds($interfaceGroupIds);
foreach ($groups as $group) {
$groupId = (string) $group['permission_group_id'];
$groupDw = XenForo_DataWriter::create('XenForo_DataWriter_PermissionGroup');
if (isset($existingGroups[$groupId])) {
$groupDw->setExistingData($existingGroups[$groupId], true);
}
$groupDw->setOption(XenForo_DataWriter_PermissionGroup::OPTION_REBUILD_CACHE, false);
$groupDw->bulkSet(array('permission_group_id' => $groupId, 'addon_id' => $addOnId));
$groupDw->save();
}
foreach ($permissions as $permission) {
$groupId = (string) $permission['permission_group_id'];
$permissionId = (string) $permission['permission_id'];
$permissionDw = XenForo_DataWriter::create('XenForo_DataWriter_Permission');
if (isset($existingPermissions[$groupId], $existingPermissions[$groupId][$permissionId])) {
$permissionDw->setExistingData($existingPermissions[$groupId][$permissionId], true);
}
$permissionDw->setOption(XenForo_DataWriter_Permission::OPTION_REBUILD_CACHE, false);
$permissionDw->setOption(XenForo_DataWriter_Permission::OPTION_DEPENDENT_CHECK, false);
$permissionDw->bulkSet(array('permission_id' => (string) $permission['permission_id'], 'permission_group_id' => (string) $permission['permission_group_id'], 'permission_type' => (string) $permission['permission_type'], 'depend_permission_id' => (string) $permission['depend_permission_id'], 'interface_group_id' => (string) $permission['interface_group_id'], 'display_order' => (string) $permission['display_order'], 'addon_id' => $addOnId));
if ((string) $permission['permission_type'] == 'integer') {
$permissionDw->set('default_value_int', (string) $permission['default_value_int']);
} else {
$permissionDw->set('default_value', (string) $permission['default_value']);
}
$permissionDw->save();
}
foreach ($interfaceGroups as $group) {
$groupId = (string) $group['interface_group_id'];
$groupDw = XenForo_DataWriter::create('XenForo_DataWriter_PermissionInterfaceGroup');
if (isset($existingInterfaceGroups[$groupId])) {
$groupDw->setExistingData($existingInterfaceGroups[$groupId], true);
}
$groupDw->bulkSet(array('interface_group_id' => $groupId, 'display_order' => (string) $group['display_order'], 'addon_id' => $addOnId));
$groupDw->save();
}
XenForo_Db::commit($db);
}
示例13: importCronEntriesAddOnXml
/**
* Imports the cron entries for an add-on.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the event data
* @param string $addOnId Add-on to import for
*/
public function importCronEntriesAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
$addonEntries = $this->getCronEntriesByAddOnId($addOnId);
XenForo_Db::beginTransaction($db);
$this->deleteCronEntriesForAddOn($addOnId);
$xmlEntries = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->entry);
$entryIds = array();
foreach ($xmlEntries as $entry) {
$entryIds[] = (string) $entry['entry_id'];
}
$entries = $this->getCronEntriesByIds($entryIds);
foreach ($xmlEntries as $entry) {
$entryId = (string) $entry['entry_id'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_CronEntry');
if (isset($entries[$entryId])) {
$dw->setExistingData($entries[$entryId]);
}
if (isset($addonEntries[$entryId])) {
$active = $addonEntries[$entryId]['active'];
} else {
$active = (string) $entry['active'];
}
$dw->setOption(XenForo_DataWriter_CronEntry::OPTION_REBUILD_CACHE, false);
$dw->bulkSet(array('entry_id' => $entryId, 'cron_class' => (string) $entry['cron_class'], 'cron_method' => (string) $entry['cron_method'], 'active' => $active, 'run_rules' => json_decode((string) $entry, true), 'addon_id' => $addOnId));
$dw->save();
}
$this->updateMinimumNextRunTime();
XenForo_Db::commit($db);
}
示例14: importModificationAddOnXml
/**
* Imports the modifications for an add-on.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the event data
* @param string $addOnId Add-on to import for
*/
public function importModificationAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
$addonMods = $this->getModificationsByAddOnId($addOnId);
XenForo_Db::beginTransaction($db);
$this->deleteModificationsForAddOn($addOnId);
$xmlEntries = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->modification);
$keys = array();
foreach ($xmlEntries as $entry) {
$keys[] = (string) $entry['modification_key'];
}
$modifications = $this->getModificationsByKeys($keys);
foreach ($xmlEntries as $modification) {
$key = (string) $modification['modification_key'];
$dw = XenForo_DataWriter::create($this->_dataWriterName);
if (isset($modifications[$key])) {
$dw->setExistingData($modifications[$key]);
}
if (isset($addonMods[$key])) {
$enabled = $addonMods[$key]['enabled'];
} else {
$enabled = (string) $modification['enabled'];
}
$dw->setOption(XenForo_DataWriter_TemplateModificationAbstract::OPTION_FULL_TEMPLATE_COMPILE, false);
$dw->setOption(XenForo_DataWriter_TemplateModificationAbstract::OPTION_REPARSE_TEMPLATE, false);
$dw->setOption(XenForo_DataWriter_TemplateModificationAbstract::OPTION_VERIFY_MODIFICATION_KEY, false);
$dw->bulkSet(array('addon_id' => $addOnId, 'template' => (string) $modification['template'], 'modification_key' => $key, 'description' => (string) $modification['description'], 'execution_order' => (int) $modification['execution_order'], 'enabled' => $enabled, 'action' => (string) $modification['action'], 'find' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($modification->find[0]), 'replace' => XenForo_Helper_DevelopmentXml::processSimpleXmlCdata($modification->replace[0])));
$this->_addExtraToAddonXmlImportDw($dw, $modification);
$dw->save();
}
XenForo_Db::commit($db);
}
示例15: importAdminPermissionsAddOnXml
/**
* Imports the add-on admin permission XML.
*
* @param SimpleXMLElement $xml XML element pointing to the root of the data
* @param string $addOnId Add-on to import for
*/
public function importAdminPermissionsAddOnXml(SimpleXMLElement $xml, $addOnId)
{
$db = $this->_getDb();
XenForo_Db::beginTransaction($db);
$this->deleteAdminPermissionsForAddOn($addOnId);
$xmlPermissions = XenForo_Helper_DevelopmentXml::fixPhpBug50670($xml->admin_permission);
$adminPermissionIds = array();
foreach ($xmlPermissions as $adminPermission) {
$adminPermissionIds[] = (string) $adminPermission['admin_permission_id'];
}
$existingPermissions = $this->getAdminPermissionsByIds($adminPermissionIds);
foreach ($xmlPermissions as $adminPermission) {
$adminPermissionId = (string) $adminPermission['admin_permission_id'];
$dw = XenForo_DataWriter::create('XenForo_DataWriter_AdminPermission');
if (isset($existingPermissions[$adminPermissionId])) {
$dw->setExistingData($existingPermissions[$adminPermissionId], true);
}
$dw->bulkSet(array('admin_permission_id' => $adminPermissionId, 'display_order' => (string) $adminPermission['display_order'], 'addon_id' => $addOnId));
$dw->save();
}
$this->rebuildUserAdminPermissionCache();
XenForo_Db::commit($db);
}