本文整理匯總了PHP中ImpExData::import_category方法的典型用法代碼示例。如果您正苦於以下問題:PHP ImpExData::import_category方法的具體用法?PHP ImpExData::import_category怎麽用?PHP ImpExData::import_category使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ImpExData
的用法示例。
在下文中一共展示了ImpExData::import_category方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: init
function init(&$sessionobject, &$displayobject, &$Db_target, &$Db_source)
{
if ($this->check_order($sessionobject, $this->_dependent)) {
if ($this->_restart) {
if ($this->restart($sessionobject, $displayobject, $Db_target, $Db_source, 'clear_imported_forums')) {
$displayobject->display_now("<h4>{$displayobject->phrases['forums_cleared']}</h4>");
$this->_restart = true;
} else {
$sessionobject->add_error(substr(get_class($this), -3), $displayobject->phrases['forum_restart_failed'], $displayobject->phrases['check_db_permissions']);
}
}
// Start up the table
$displayobject->update_basic('title', $displayobject->phrases['import_forum']);
$displayobject->update_html($displayobject->do_form_header('index', substr(get_class($this), -3)));
$displayobject->update_html($displayobject->make_hidden_code(substr(get_class($this), -3), 'WORKING'));
$displayobject->update_html($displayobject->make_hidden_code('import_forum', 'working'));
$displayobject->update_html($displayobject->make_table_header($this->_modulestring));
// Ask some questions
$displayobject->update_html($displayobject->make_input_code($displayobject->phrases['forums_per_page'], 'forumperpage', 500));
// End the table
$displayobject->update_html($displayobject->do_form_footer($displayobject->phrases['continue'], $displayobject->phrases['reset']));
// Reset/Setup counters for this
$sessionobject->add_session_var(substr(get_class($this), -3) . '_objects_done', '0');
$sessionobject->add_session_var(substr(get_class($this), -3) . '_objects_failed', '0');
$sessionobject->add_session_var('forumstartat', '0');
$target_database_type = $sessionobject->get_session_var('targetdatabasetype');
$target_table_prefix = $sessionobject->get_session_var('targettableprefix');
$sessionobject->add_session_var('categoriesfinished', 'FALSE');
// Default
$target_database_type = $sessionobject->get_session_var('targetdatabasetype');
$target_table_prefix = $sessionobject->get_session_var('targettableprefix');
$try = new ImpExData($Db_target, $sessionobject, 'forum');
$try->set_value('mandatory', 'title', 'Default cat');
$try->set_value('mandatory', 'displayorder', '1');
$try->set_value('mandatory', 'parentid', '-1');
$try->set_value('mandatory', 'options', $this->_default_cat_permissions);
$try->set_value('mandatory', 'importforumid', '0');
$try->set_value('mandatory', 'importcategoryid', '1');
$try->import_category($Db_target, $target_database_type, $target_table_prefix);
unset($try);
} else {
// Dependant has not been run
$displayobject->update_html($displayobject->do_form_header('index', ''));
$displayobject->update_html($displayobject->make_description("<p>{$displayobject->phrases['dependant_on']}<i><b> " . $sessionobject->get_module_title($this->_dependent) . "</b> {$displayobject->phrases['cant_run']}</i> ."));
$displayobject->update_html($displayobject->do_form_footer($displayobject->phrases['continue'], ''));
$sessionobject->set_session_var(substr(get_class($this), -3), 'FALSE');
$sessionobject->set_session_var('module', '000');
}
}
示例2: init
function init(&$sessionobject, &$displayobject, &$Db_target, &$Db_source)
{
if ($this->check_order($sessionobject, $this->_dependent)) {
if ($this->_restart) {
if ($this->restart($sessionobject, $displayobject, $Db_target, $Db_source, 'clear_imported_forums')) {
$displayobject->display_now('<h4>Imported forums have been cleared</h4>');
$this->_restart = true;
} else {
$sessionobject->add_error('fatal', $this->_modulestring, get_class($this) . '::restart failed , clear_imported_forums', 'Check database permissions');
}
}
// Start up the table
$displayobject->update_basic('title', 'Import Forum');
$displayobject->update_html($displayobject->do_form_header('index', substr(get_class($this), -3)));
$displayobject->update_html($displayobject->make_hidden_code(substr(get_class($this), -3), 'WORKING'));
$displayobject->update_html($displayobject->make_hidden_code('import_forum', 'working'));
$displayobject->update_html($displayobject->make_table_header($this->_modulestring));
// Ask some questions
$displayobject->update_html($displayobject->make_input_code('Forums to import per cycle (must be greater than 1)', 'forumperpage', 500));
// End the table
$displayobject->update_html($displayobject->do_form_footer('Continue', 'Reset'));
// Reset/Setup counters for this
$sessionobject->add_session_var(substr(get_class($this), -3) . '_objects_done', '0');
$sessionobject->add_session_var(substr(get_class($this), -3) . '_objects_failed', '0');
$sessionobject->add_session_var('forumstartat', '0');
$sessionobject->add_session_var('forumdone', '0');
// Setup default cat
$category_object = new ImpExData($Db_target, $sessionobject, 'forum');
$category_object->set_value('mandatory', 'title', 'Default import category');
$category_object->set_value('mandatory', 'displayorder', '1');
$category_object->set_value('mandatory', 'parentid', '-1');
$category_object->set_value('mandatory', 'options', $this->_default_cat_permissions);
$category_object->set_value('mandatory', 'importforumid', '0');
$category_object->set_value('mandatory', 'importcategoryid', '1');
$cat_id = $category_object->import_category($Db_target, $sessionobject->get_session_var('targetdatabasetype'), $sessionobject->get_session_var('targettableprefix'));
$sessionobject->add_session_var('importcatid', $cat_id);
} else {
// Dependant has not been run
$displayobject->update_html($displayobject->do_form_header('index', ''));
$displayobject->update_html($displayobject->make_description('<p>This module is dependent on <i><b>' . $sessionobject->get_module_title($this->_dependent) . '</b></i> cannot run until that is complete.'));
$displayobject->update_html($displayobject->do_form_footer('Continue', ''));
$sessionobject->set_session_var(substr(get_class($this), -3), 'FALSE');
$sessionobject->set_session_var('module', '000');
}
}
示例3: resume
function resume(&$sessionobject, &$displayobject, &$Db_target, &$Db_source)
{
// Set up working variables.
$displayobject->update_basic('displaymodules', 'FALSE');
$target_database_type = $sessionobject->get_session_var('targetdatabasetype');
$target_table_prefix = $sessionobject->get_session_var('targettableprefix');
$source_database_type = $sessionobject->get_session_var('sourcedatabasetype');
$source_table_prefix = $sessionobject->get_session_var('sourcetableprefix');
// Per page vars
$forum_start_at = $sessionobject->get_session_var('forumstartat');
$forum_per_page = $sessionobject->get_session_var('forumperpage');
$class_num = substr(get_class($this), -3);
// Start the timing
if (!$sessionobject->get_session_var($class_num . '_start')) {
$sessionobject->timing($class_num, 'start', $sessionobject->get_session_var('autosubmit'));
}
// Get an array of forum details
$forum_array = $this->get_freethreads_forum_details($Db_source, $source_database_type, $source_table_prefix, $forum_start_at, $forum_per_page);
if ($sessionobject->get_session_var('categoriesfinished') == 'FALSE') {
$category_object = new ImpExData($Db_target, $sessionobject, 'forum');
$category_object->set_value('mandatory', 'title', 'free threads category');
$category_object->set_value('mandatory', 'displayorder', '1');
$category_object->set_value('mandatory', 'parentid', '-1');
$category_object->set_value('mandatory', 'importforumid', '0');
$category_object->set_value('mandatory', 'importcategoryid', '1');
$category_object->set_value('mandatory', 'options', $this->_default_cat_permissions);
$category_object->import_category($Db_target, $target_database_type, $target_table_prefix);
$sessionobject->add_session_var('categoriesfinished', 'TRUE');
}
$cat_ids_array = $this->get_category_ids($Db_target, $target_database_type, $target_table_prefix);
// Display count and pass time
$displayobject->display_now('<h4>Importing ' . count($forum_array) . ' forums</h4><p><b>From</b> : ' . $forum_start_at . ' :: <b>To</b> : ' . ($forum_start_at + count($forum_array)) . '</p>');
$forum_object = new ImpExData($Db_target, $sessionobject, 'forum');
foreach ($forum_array as $forum_id => $forum_details) {
$try = phpversion() < '5' ? $forum_object : clone $forum_object;
// Mandatory
$try->set_value('mandatory', 'title', $forum_details['NAME']);
$try->set_value('mandatory', 'displayorder', $forum_details['RANK']);
$try->set_value('mandatory', 'parentid', $cat_ids_array[1]);
$try->set_value('mandatory', 'importforumid', $forum_id);
$try->set_value('mandatory', 'importcategoryid', '1');
$try->set_value('mandatory', 'options', $this->_default_forum_permissions);
// Non Mandatory
$try->set_value('nonmandatory', 'description', $forum_details['DESCRIPTION']);
$try->set_value('nonmandatory', 'replycount', $forum_details['TOTAL']);
$try->set_value('nonmandatory', 'lastpost', $forum_details['LAST']);
// Check if forum object is valid
if ($try->is_valid()) {
if ($try->import_forum($Db_target, $target_database_type, $target_table_prefix)) {
$displayobject->display_now('<br /><span class="isucc"><b>' . $try->how_complete() . '%</b></span> :: forum -> ' . $forum_details['NAME']);
$sessionobject->add_session_var($class_num . '_objects_done', intval($sessionobject->get_session_var($class_num . '_objects_done')) + 1);
} else {
$sessionobject->set_session_var($class_num . '_objects_failed', $sessionobject->get_session_var($class_num . '_objects_failed') + 1);
$sessionobject->add_error('warning', $this->_modulestring, get_class($this) . '::import_custom_profile_pic failed.', 'Check database permissions and database table');
$displayobject->display_now("<br />Found avatar forum and <b>DID NOT</b> imported to the {$target_database_type} database");
}
} else {
$displayobject->display_now("<br />Invalid forum object, skipping." . $try->_failedon);
}
unset($try);
}
// End foreach
// Check for page end
if (count($forum_array) == 0 or count($forum_array) < $forum_per_page) {
$sessionobject->timing($class_num, 'stop', $sessionobject->get_session_var('autosubmit'));
$sessionobject->remove_session_var($class_num . '_start');
$forum_ids_array = $this->get_forum_ids($Db_target, $target_database_type, $target_table_prefix);
$this->build_forum_child_lists($Db_target, $target_database_type, $target_table_prefix);
$displayobject->update_html($displayobject->module_finished($this->_modulestring, $sessionobject->return_stats($class_num, '_time_taken'), $sessionobject->return_stats($class_num, '_objects_done'), $sessionobject->return_stats($class_num, '_objects_failed')));
$sessionobject->set_session_var($class_num, 'FINISHED');
$sessionobject->set_session_var('import_forum', 'done');
$sessionobject->set_session_var('module', '000');
$sessionobject->set_session_var('autosubmit', '0');
$displayobject->update_html($displayobject->print_redirect('index.php', '1'));
}
$sessionobject->set_session_var('forumstartat', $forum_start_at + $forum_per_page);
$displayobject->update_html($displayobject->print_redirect('index.php'));
}
示例4: array
function parse_folder($data)
{
/*
// this method is not particularly extensible. Using these flags, 2 bits
// were found to always be on, 0x180000. Any forum with either of these
// bits will now be imported
$valid_folder_flags = array(
'00181000',
'00190800',
'00191000',
'00193000',
'001B1800',
'08181000',
'08190800',
'081B1800',
);
if ($data['type'] == 'open' AND in_array($data['attributes']['flags'], $valid_folder_flags))
*/
if ($data['type'] == 'open') {
if ($forum =& $this->get_first_tag('folder') and !empty($forum['__ignorechildren'])) {
// we're ignoring a parent, so ignore this one as well
$data['__ignorechildren'] = true;
$this->push_stack($data);
return;
}
if (!(hexdec($data['attributes']['flags']) & 0x180000) or in_array(trim($data['attributes']['name']), array('In', 'system', 'common', 'Click Here to Begin', 'Quick Help', 'plugins', 'Templates', 'webxTemplates', 'Images'))) {
// wrong flags or is a special forum we don't want, so
// don't import it and ignore any children it may have
$data['__ignorechildren'] = true;
$this->push_stack($data);
return;
} else {
$this->push_stack($data);
}
$stack_size = $this->fetch_stack_size();
if ($stack_size == 0) {
//eeke !
die('no push');
} else {
if ($stack_size == 1) {
// One deep its a cat
$category_object = new ImpExData($this->Db_object, $this->session, 'forum');
$category_object->set_value('mandatory', 'title', $data['attributes']['title'] ? $data['attributes']['title'] : $data['attributes']['name']);
$category_object->set_value('mandatory', 'displayorder', '1');
$category_object->set_value('mandatory', 'parentid', '-1');
$category_object->set_value('mandatory', 'importforumid', '0');
$category_object->set_value('mandatory', 'importcategoryid', hexdec($data['attributes']['unique']));
$category_object->set_value('mandatory', 'options', $this->_default_cat_permissions);
$category_object->set_value('nonmandatory', 'description', $data['attributes']['heading']);
if ($cat_id = $category_object->import_category($this->Db_object, $this->target_db_type, $this->target_db_prefix)) {
echo "<br /><span class=\"isucc\">Category -- <b>" . $category_object->how_complete() . "%</b></span> :: " . $category_object->get_value('mandatory', 'title');
$this->session->add_session_var('currentcat', $cat_id);
$this->session->add_session_var('currentforum', $cat_id);
flush();
} else {
echo "<br />'" . trim($attributes['attributes']['name']) . " not imported";
}
unset($category_object);
} else {
if ($stack_size == 2) {
// Two deep its a forum
$forum_object = new ImpExData($this->Db_object, $this->session, 'forum');
$forum_object->set_value('mandatory', 'parentid', $this->session->get_session_var('currentcat'));
$forum_object->set_value('mandatory', 'title', $data['attributes']['name']);
$forum_object->set_value('mandatory', 'displayorder', $data['attributes']['sortSeq']);
$forum_object->set_value('mandatory', 'importforumid', hexdec($data['attributes']['unique']));
$forum_object->set_value('mandatory', 'importcategoryid', '0');
$forum_object->set_value('mandatory', 'options', $this->_default_forum_permissions);
$forum_object->set_value('nonmandatory', 'description', $forum['heading']);
$forum_object->set_value('nonmandatory', 'visible', '1');
if ($forum_id = $forum_object->import_forum($this->Db_object, $this->target_db_type, $this->target_db_prefix)) {
echo "<br /><span class=\"isucc\">Forum -- <b>" . $forum_object->how_complete() . "%</b></span> :: forum " . $forum_object->get_value('mandatory', 'title');
$this->session->add_session_var('currentforum', $forum_id);
flush();
} else {
echo "<br />'" . trim($data['attributes']['name']) . " not imported";
}
unset($forum_object);
} else {
// Two deep its a sub forum, with a folder tag
$forum_object = new ImpExData($this->Db_object, $this->session, 'forum');
$forum_object->set_value('mandatory', 'parentid', $this->session->get_session_var('currentforum'));
$forum_object->set_value('mandatory', 'title', $data['attributes']['name']);
$forum_object->set_value('mandatory', 'displayorder', $data['attributes']['sortSeq']);
$forum_object->set_value('mandatory', 'importforumid', hexdec($data['attributes']['unique']));
$forum_object->set_value('mandatory', 'importcategoryid', '0');
$forum_object->set_value('mandatory', 'options', $this->_default_forum_permissions);
$forum_object->set_value('nonmandatory', 'description', $forum['heading']);
$forum_object->set_value('nonmandatory', 'visible', '1');
if ($forum_id = $forum_object->import_forum($this->Db_object, $this->target_db_type, $this->target_db_prefix)) {
echo "<br /><span class=\"isucc\">Sub Forum -- <b>" . $forum_object->how_complete() . "%</b></span> :: forum " . $forum_object->get_value('mandatory', 'title');
$this->session->add_session_var('currentforum', $forum_id);
flush();
} else {
echo "<br />'" . trim($data['attributes']['name']) . " not imported";
}
unset($forum_object);
}
}
}
//.........這裏部分代碼省略.........