Ejemplo n.º 1
0
 protected function setup_mainpanel(PlansPage $page)
 {
     $tpl = new Plans_Savant3();
     $panel = $page->mainpanel;
     $tpl->panel = $panel;
     $tpl->links_template = $this->setup_links($panel->links);
     $tpl->setTemplate('views/templates/legacy/Mainpanel.tpl.php');
     return $tpl;
 }
Ejemplo n.º 2
0
 protected function setup_widget(Widget $obj)
 {
     $tpl = parent::setup_widget($obj);
     if ($obj instanceof NotesTopic && $obj->summary) {
         // Override the forced lowercase that gets applied to Hyperlinks
         $tpl->title_template->description = $obj->title->description;
         $tpl->setTemplate('views/templates/legacy/NotesBoardTopic.tpl.php');
     } else {
         if ($obj instanceof WidgetGroup) {
             if ($obj instanceof Form) {
                 foreach ($obj->contents as $i => $item) {
                     if ($item instanceof SubmitInput) {
                         $tpl->submit_button = $item;
                     }
                 }
                 $tpl->setTemplate('views/templates/legacy/Form.tpl.php');
                 if ($this->page->identifier == 'planname' || $this->page->identifier == 'search') {
                     $tpl = $this->oneline_form($obj, $tpl);
                 } else {
                     if ($obj->identifier == 'signup') {
                         $tpl->contents[2]->setTemplate('views/templates/legacy/FormElement_no_table.tpl.php');
                     } else {
                         if ($this->page->identifier == 'poll') {
                             $tpl->setTemplate('views/templates/legacy/PollForm.tpl.php');
                         }
                     }
                 }
                 if ($obj instanceof EditBox) {
                     $tpl->setTemplate('views/templates/legacy/EditBox.tpl.php');
                 }
             } else {
                 if ($obj instanceof FormItemSet) {
                     $tpl->tag_attributes = self::id_and_class($obj->identifier, array($obj->group, 'formitemset'));
                     foreach ($tpl->contents as $template) {
                         $template->setTemplate('views/templates/legacy/FormElement_no_row.tpl.php');
                     }
                     $tpl->setTemplate('views/templates/legacy/FormItemSet.tpl.php');
                 } else {
                     if ($obj instanceof NotesBoard) {
                         foreach ($tpl->contents as $t) {
                             $t->list_attributes = str_replace('even', 'noteslight', $t->list_attributes);
                             $t->list_attributes = str_replace('odd', 'notesdark', $t->list_attributes);
                         }
                         $tpl->setTemplate('views/templates/legacy/NotesBoard.tpl.php');
                     } else {
                         if ($obj instanceof NotesTopic) {
                             $tpl->tag_attributes = ' class="boardmessages"';
                             foreach ($tpl->contents as $t) {
                                 $t->list_attributes = str_replace('even', 'noteslight', $t->list_attributes);
                                 $t->list_attributes = str_replace('odd', 'notesdark', $t->list_attributes);
                             }
                             $tpl->setTemplate('views/templates/legacy/NotesTopic.tpl.php');
                         } else {
                             if ($obj instanceof WidgetList) {
                                 $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                                 $tpl->setTemplate('views/templates/legacy/WidgetList.tpl.php');
                                 // The Preferences page
                                 if ($this->page->identifier == 'prefs') {
                                     $part2 = false;
                                     foreach ($obj->contents as $i => $item) {
                                         $t = $tpl->contents[$i];
                                         if ($part2) {
                                             $t->tag_attributes = ' class="lev2"';
                                         } else {
                                             if ($item instanceof HeadingText) {
                                                 $t->tag_attributes = ' class="main"';
                                                 $t->tag = 'p';
                                                 $t->setTemplate('views/templates/std/GenericTag.tpl.php');
                                                 $part2 = true;
                                             } else {
                                                 $t->tag_attributes = ' class="main"';
                                             }
                                         }
                                     }
                                 } else {
                                     if ($obj->identifier == 'autoread_alphabet') {
                                         $tpl->setTemplate('views/templates/legacy/WidgetGroup.tpl.php');
                                     } else {
                                         if ($obj->identifier == 'search_results' || $obj->group == 'result_sublist') {
                                             blkafkjaass;
                                             $tpl->setTemplate('views/templates/tableless/WidgetList.tpl.php');
                                         }
                                     }
                                 }
                             } else {
                                 if ($obj instanceof WidgetGroup) {
                                     $tpl->setTemplate('views/templates/legacy/WidgetGroup.tpl.php');
                                     if ($obj->group == 'notes_header') {
                                         $t = $tpl;
                                         $tpl = new Plans_Savant3();
                                         $tpl->inner_template = $t;
                                         $tpl->tag = 'center';
                                         $tpl->setTemplate('views/templates/std/GenericWrapperTag.tpl.php');
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
             return $tpl;
             //TODO remove
         } else {
             if ($obj instanceof SubmitInput) {
                 // We handle this elsewhere, so print nothing here
                 $tpl->setTemplate('views/templates/std/Empty.tpl.php');
             } else {
                 if ($obj instanceof FormItem) {
                     if ($obj instanceof HiddenInput) {
                         $tpl->setTemplate('views/templates/std/FormInput.tpl.php');
                     } else {
                         if ($obj instanceof TextInput || $obj instanceof TextareaInput || $obj instanceof PasswordInput) {
                             $tpl->setTemplate('views/templates/legacy/FormElement_title_prepend.tpl.php');
                         } else {
                             $tpl->setTemplate('views/templates/legacy/FormElement.tpl.php');
                         }
                     }
                 } else {
                     if ($obj instanceof Hyperlink) {
                         $tpl->description = strtolower($obj->description);
                         if ($obj->identifier == 'older_secrets') {
                             $t = $tpl;
                             $tpl = new Plans_Savant3();
                             $tpl->inner_template = $t;
                             $tpl->tag = 'p';
                             $tpl->setTemplate('views/templates/std/GenericWrapperTag.tpl.php');
                         }
                     } else {
                         if ($obj instanceof Secret) {
                             $tpl->message = preg_replace('/(^<p class="sub">)|(<\\/p>$)/', '', $tpl->message);
                             $tpl->setTemplate('views/templates/legacy/Secret.tpl.php');
                         } else {
                             if ($obj instanceof PlanContent) {
                                 if ($obj->addform) {
                                     $tpl->addform_present = true;
                                     $tpl->addform_template = $this->oneline_form($obj->addform, $tpl->addform_template);
                                     $tpl->addform_template->setTemplate('views/templates/legacy/addform.tpl.php');
                                 } else {
                                     $tpl->addform_present = false;
                                 }
                                 $tpl->setTemplate('views/templates/legacy/Plan.tpl.php');
                             } else {
                                 if ($obj instanceof PlanText) {
                                     $tpl->setTemplate('views/templates/legacy/PlanText.tpl.php');
                                 } else {
                                     if ($obj instanceof HeadingText) {
                                         $tpl->tag = 'h' . ($obj->sublevel + 1);
                                         $tpl->text = $obj->message;
                                         $tpl->setTemplate('views/templates/std/GenericTag.tpl.php');
                                     } else {
                                         if ($obj instanceof RegularText) {
                                             $tpl->tag = 'span';
                                             $tpl->text = $obj->message;
                                             $tpl->setTemplate('views/templates/std/GenericTag.tpl.php');
                                         } else {
                                             if ($obj instanceof Text) {
                                                 $tpl->setTemplate('views/templates/legacy/Text.tpl.php');
                                             } else {
                                                 if ($obj instanceof NotesPost) {
                                                     $tpl->text = preg_replace('/(^<p class="sub">)|(<\\/p>$)/', '', $tpl->text);
                                                     $tpl->yes_style = $obj->user_vote == 'yes' ? ' style="border:#222222 thin solid"' : null;
                                                     $tpl->no_style = $obj->user_vote == 'no' ? ' style="border:#222222 thin solid"' : null;
                                                     $tpl->setTemplate('views/templates/legacy/NotesPost.tpl.php');
                                                 } else {
                                                     if ($obj instanceof NotesNavigation) {
                                                         $tpl->current->text = '[' . $tpl->current->text . ']';
                                                         $tpl->setTemplate('views/templates/legacy/NotesNavigation.tpl.php');
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $tpl;
 }
Ejemplo n.º 3
0
 protected function setup_widget(Widget $obj)
 {
     $tpl = new Plans_Savant3();
     if ($obj instanceof NotesTopic && $obj->summary) {
         $tpl->title_template = $this->setup_widget($obj->title);
         $tpl->updated = $obj->updated;
         $tpl->posts = $obj->posts;
         if (is_null($obj->firstposter)) {
             $tpl->firstposter_template = $this->setup_widget(new RegularText('User Deleted'));
         } else {
             $tpl->firstposter_template = $this->setup_widget($obj->firstposter);
         }
         if (is_null($obj->lastposter)) {
             $tpl->lastposter_template = $this->setup_widget(new RegularText('User Deleted'));
         } else {
             $tpl->lastposter_template = $this->setup_widget($obj->lastposter);
         }
     } else {
         if ($obj instanceof WidgetGroup) {
             $tpl->contents = array_map(array($this, 'setup_widget'), $obj->contents);
             if ($obj instanceof WidgetList) {
                 foreach ($tpl->contents as $i => $t) {
                     if ($i % 2 == 0) {
                         $class = 'even';
                     } else {
                         $class = 'odd';
                     }
                     if ($i == 0) {
                         $class .= ' first';
                     }
                     if ($i == count($obj->contents) - 1) {
                         $class .= ' last';
                     }
                     $t->list_attributes = $class;
                 }
             }
             if ($obj instanceof Form) {
                 $tpl->tag_attributes = self::id_and_class($obj->identifier, array($obj->group, 'form')) . ' enctype="multipart/form-data"';
                 $tpl->method = strtolower($obj->method);
                 $tpl->action = $obj->action;
                 if ($obj instanceof EditBox) {
                     $tpl->rows = $obj->rows;
                     $tpl->columns = $obj->columns;
                     $tpl->text = $obj->text->message;
                     $tpl->submitable = $obj->submitable;
                     //TODO This line should be the responsibility of edit.php, not this object
                     $tpl->otherinputs_template = $this->setup_widget(new HiddenInput('part', 1));
                     $tpl->button_template = $this->setup_widget(new SubmitInput('Change Plan'));
                 }
             } else {
                 if ($obj instanceof FormItemSet) {
                     $tpl->tag_attributes = self::id_and_class($obj->identifier, array($obj->group, 'formitemset'));
                     $tpl->title = $obj->title;
                 } else {
                     if ($obj instanceof AutoRead) {
                         $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                         $tpl->level_link_template = $this->setup_widget($obj->link);
                         $tpl->markasread_template = $this->setup_widget($obj->markasread_link);
                     } else {
                         if ($obj instanceof NotesBoard) {
                             $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                         } else {
                             if ($obj instanceof NotesTopic) {
                                 $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                                 $tpl->title_template = $this->setup_widget($obj->title);
                             } else {
                                 if ($obj instanceof WidgetList) {
                                     $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                                 } else {
                                     if ($obj instanceof WidgetGroup) {
                                         $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         } else {
             if ($obj instanceof SubmitInput) {
                 if ($obj->name) {
                     $tpl->tag_attributes .= " name=\"{$obj->name}\"";
                 }
                 $tpl->text = $obj->value;
             } else {
                 if ($obj instanceof FormItem) {
                     if ($obj->identifier) {
                         $item_id = $obj->identifier;
                     } else {
                         $item_id = $obj->parent_form->identifier . '_' . $obj->name;
                     }
                     $item_id = str_replace('[]', '', $item_id);
                     // If it's possible there are multiple inputs with the same name,
                     // append a number to the end to make it unique
                     if ($obj instanceof CheckboxInput || $obj instanceof RadioInput) {
                         if (!isset($this->element_ids[$item_id])) {
                             $this->element_ids[$item_id] = 0;
                         }
                         $num = (int) $this->element_ids[$item_id]++;
                         $item_id = $item_id . $num;
                     }
                     $tpl->label = $obj->title;
                     $tpl->description = $obj->description;
                     $tpl->prompt_id = $item_id;
                     $tpl->type = $obj->type;
                     $tpl->name = $obj->name;
                     $tpl->value = $obj->value;
                     $tpl->disabled = $obj->disabled;
                     if (isset($obj->readonly)) {
                         $tpl->readonly = $obj->readonly;
                     }
                     if (isset($obj->checked)) {
                         $tpl->checked = $obj->checked;
                     }
                     if (isset($obj->rows)) {
                         $tpl->rows = $obj->rows;
                     }
                     if (isset($obj->cols)) {
                         $tpl->cols = $obj->cols;
                     }
                 } else {
                     if ($obj instanceof Hyperlink) {
                         $tpl->href = htmlentities(html_entity_decode($obj->href));
                         $tpl->description = $obj->description;
                         $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                         $tpl->setTemplate('views/templates/std/Hyperlink.tpl.php');
                         if ($obj instanceof DisplayToggleLink) {
                             $tpl->onclick = "toggleShowHide('{$obj->target_id}', this, '{$obj->show_desc}', '{$obj->hide_desc}')";
                             if ($obj->initially_hidden) {
                                 $tpl->js = "document.getElementById('{$obj->target_id}').style.display = 'none';";
                             }
                             $tpl->setTemplate('views/templates/std/DisplayToggleLink.tpl.php');
                         }
                     } else {
                         if ($obj instanceof Secret) {
                             $tpl->date = $obj->date;
                             $tpl->secret_id = $obj->secret_id;
                             $tpl->message = $obj->message;
                         } else {
                             if ($obj instanceof PlanContent) {
                                 $tpl->username = $obj->username;
                                 $tpl->lastupdate = $obj->lastupdate;
                                 $tpl->lastlogin = $obj->lastlogin;
                                 $tpl->planname = $obj->planname;
                                 $tpl->plan_template = $this->setup_widget($obj->text);
                                 if ($obj->addform) {
                                     $tpl->addform_template = $this->setup_widget($obj->addform);
                                 }
                             } else {
                                 if ($obj instanceof PlanText) {
                                     $tpl->text = $obj->message;
                                 } else {
                                     if ($obj instanceof HeadingText) {
                                         $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                                         $tpl->tag = 'h' . $obj->sublevel;
                                         $tpl->text = $obj->message;
                                         $tpl->setTemplate('views/templates/std/GenericTag.tpl.php');
                                     } else {
                                         if ($obj instanceof RegularText) {
                                             $tpl->tag = 'span';
                                             $tpl->text = $obj->message;
                                             $tpl->setTemplate('views/templates/std/GenericTag.tpl.php');
                                         } else {
                                             if ($obj instanceof Text) {
                                                 $tpl->tag_attributes = self::id_and_class($obj->identifier, $obj->group);
                                                 $tpl->title = $obj->title;
                                                 $tpl->message = $obj->message;
                                             } else {
                                                 if ($obj instanceof NotesPost) {
                                                     $tpl->post_id = $obj->id;
                                                     $tpl->date = $obj->date;
                                                     $tpl->post_author_template = $this->setup_widget($obj->poster);
                                                     $tpl->score = $obj->score;
                                                     $tpl->user_vote = $obj->user_vote;
                                                     $tpl->votes = $obj->votes;
                                                     $tpl->text = $obj->contents;
                                                 } else {
                                                     if ($obj instanceof NotesNavigation) {
                                                         $tpl->tag_attributes = self::id_and_class($obj->identifier, array($obj->group, 'notes_nav'));
                                                         if ($obj->newest instanceof Hyperlink) {
                                                             $tpl->newest = $this->setup_widget($obj->newest);
                                                             $tpl->newest->description = '&lt;&lt;';
                                                             $tpl->navigable['newest'] = true;
                                                         } else {
                                                             $tpl->newest = new Plans_Savant3();
                                                             $tpl->newest->setTemplate('views/templates/std/GenericTag.tpl.php');
                                                             $tpl->newest->text = '&lt;&lt;';
                                                             $tpl->newest->tag = 'span';
                                                             $tpl->navigable['newest'] = false;
                                                         }
                                                         foreach (array('even_newer', 'newer', 'current', 'older', 'even_older') as $linkname) {
                                                             if ($obj->{$linkname} instanceof Hyperlink || $linkname == 'current') {
                                                                 $tpl->{$linkname} = $this->setup_widget($obj->{$linkname});
                                                                 $tpl->navigable[$linkname] = true;
                                                             } else {
                                                                 $tpl->{$linkname} = new Plans_Savant3();
                                                                 $tpl->{$linkname}->setTemplate('views/templates/std/GenericTag.tpl.php');
                                                                 $tpl->{$linkname}->text = '_';
                                                                 $tpl->{$linkname}->tag = 'span';
                                                                 $tpl->navigable[$linkname] = false;
                                                             }
                                                         }
                                                         if ($obj->oldest instanceof Hyperlink) {
                                                             $tpl->oldest = $this->setup_widget($obj->oldest);
                                                             $tpl->oldest->description = '&gt;&gt;';
                                                             $tpl->navigable['oldest'] = true;
                                                         } else {
                                                             $tpl->oldest = new Plans_Savant3();
                                                             $tpl->oldest->setTemplate('views/templates/std/GenericTag.tpl.php');
                                                             $tpl->oldest->text = '&gt;&gt;';
                                                             $tpl->oldest->tag = 'span';
                                                             $tpl->navigable['oldest'] = false;
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     return $tpl;
 }