3 class YammerProgressForm extends Form
8 * @return string ID of the form
12 return 'yammer-progress';
18 * @return string class of the form
22 return 'form_settings';
28 * @return string URL of the action
32 return common_local_url('yammeradminpanel');
36 * Data elements of the form
42 $runner = YammerRunner::init();
44 $userCount = $runner->countUsers();
45 $groupCount = $runner->countGroups();
46 $fetchedCount = $runner->countFetchedNotices();
47 $savedCount = $runner->countSavedNotices();
51 'label' => _m("Initialize"),
52 'progress' => _m('No import running'),
53 'complete' => _m('Initiated Yammer server connection...'),
55 'requesting-auth' => array(
56 'label' => _m('Connect to Yammer'),
57 'progress' => _m('Awaiting authorization...'),
58 'complete' => _m('Connected.'),
60 'import-users' => array(
61 'label' => _m('Import user accounts'),
62 'progress' => sprintf(_m("Importing %d user...", "Importing %d users...", $userCount), $userCount),
63 'complete' => sprintf(_m("Imported %d user.", "Imported %d users.", $userCount), $userCount),
65 'import-groups' => array(
66 'label' => _m('Import user groups'),
67 'progress' => sprintf(_m("Importing %d group...", "Importing %d groups...", $groupCount), $groupCount),
68 'complete' => sprintf(_m("Imported %d group.", "Imported %d groups.", $groupCount), $groupCount),
70 'fetch-messages' => array(
71 'label' => _m('Prepare public notices for import'),
72 'progress' => sprintf(_m("Preparing %d notice...", "Preparing %d notices...", $fetchedCount), $fetchedCount),
73 'complete' => sprintf(_m("Prepared %d notice.", "Prepared %d notices.", $fetchedCount), $fetchedCount),
75 'save-messages' => array(
76 'label' => _m('Import public notices'),
77 'progress' => sprintf(_m("Importing %d notice...", "Importing %d notices...", $savedCount), $savedCount),
78 'complete' => sprintf(_m("Imported %d notice.", "Imported %d notices.", $savedCount), $savedCount),
81 'label' => _m('Done'),
82 'progress' => sprintf(_m("Import is complete!")),
83 'complete' => sprintf(_m("Import is complete!")),
86 $steps = array_keys($labels);
87 $currentStep = array_search($runner->state(), $steps);
89 $this->out->elementStart('fieldset', array('class' => 'yammer-import'));
90 $this->out->element('legend', array(), _m('Import status'));
91 foreach ($steps as $step => $state) {
92 if ($state == 'init') {
93 // Don't show 'init', it's boring.
96 if ($step < $currentStep) {
98 $this->progressBar($state,
100 $labels[$state]['label'],
101 $labels[$state]['complete']);
102 } else if ($step == $currentStep) {
103 // This step is in progress
104 $this->progressBar($state,
106 $labels[$state]['label'],
107 $labels[$state]['progress']);
109 // This step has not yet been done.
110 $this->progressBar($state,
112 $labels[$state]['label'],
116 $this->out->elementEnd('fieldset');
119 private function progressBar($state, $class, $label, $status)
121 // @fixme prettify ;)
122 $this->out->elementStart('div', array('class' => "import-step import-step-$state $class"));
123 $this->out->element('div', array('class' => 'import-label'), $label);
124 $this->out->element('div', array('class' => 'import-status'), $status);
125 $this->out->elementEnd('div');