public function show(Request $request) { $stylesData = \Theme::GetCSS(); $styles = null; if (file_exists($stylesData['path'])) { $styles = $stylesData['path']; } $styles = explode('/', $styles); $styles = array_pop($styles); // now check for cookies $cookie_list = $request->cookie('list_joined'); $showList = false; $showThankyou = false; // check if there is a default list if (\Configuration::get('default_list')) { $showList = true; } if (isset($cookie_list) && $cookie_list == \Configuration::get('default_list')) { $showList = false; if ($request->cookie('list_cid')) { // check if the user is on the current list... $member = ListMember::find($request->cookie('list_cid')); if ($member->list_id == \Configuration::get('default_list')) { $showThankyou = true; } } } return \Theme::display('home.front', ['user' => \Auth::user(), 'styles' => $styles, 'showList' => $showList, 'thankyou' => $showThankyou]); }
public function getEdit($id) { $content = Content::find($id); if (isset($content)) { // now get the editor scripts $scripts = [url() . '/trumbowyg/trumbowyg.min.js', url() . '/trumbowyg/plugins/upload/trumbowyg.upload.js', url() . '/trumbowyg/plugins/colors/trumbowyg.colors.js']; $styles = [url() . '/trumbowyg/ui/trumbowyg.min.css', url() . '/trumbowyg/plugins/colors/ui/trumbowyg.colors.css']; return \Theme::display('content.admin-edit', ['content' => $content, 'scripts' => $scripts, 'styles' => $styles]); } }
/** * Admin control for edit post * * @param AdminHandler $handler * @param Theme $theme * @return void */ public function action_admin_theme_post_options_edit(AdminHandler $handler, Theme $theme) { // saving is handled by FormUI $option = $this->get_option_from_name($handler->handler_vars['option_name']); $theme->option = $option; $theme->display('options_edit'); }
/** * Prepare and display admin page * **/ public function action_admin_theme_get_addons(AdminHandler $handler, Theme $theme) { $theme->page_content = ""; $theme->display('versions_admin'); }
/** * Prepare and display admin page * **/ public function action_admin_theme_get_menus(AdminHandler $handler, Theme $theme) { $theme->page_content = ''; $action = isset($_GET['action']) ? $_GET['action'] : 'create'; switch ($action) { case 'edit': $vocabulary = Vocabulary::get_by_id(intval($handler->handler_vars['menu'])); if ($vocabulary == false) { $theme->page_content = _t('<h2>Invalid Menu.</h2>', 'termmenus'); // that's it, we're done. Maybe we show the list of menus instead? break; } $form = new FormUI('edit_menu'); $form->append(new FormControlText('menuname', 'null:null', _t('Name', 'termmenus'), 'transparent_text'))->add_validator('validate_required', _t('You must supply a valid menu name', 'termmenus'))->add_validator(array($this, 'validate_newvocab'))->value = $vocabulary->name; $form->append(new FormControlHidden('oldname', 'null:null'))->value = $vocabulary->name; $form->append(new FormControlText('description', 'null:null', _t('Description', 'termmenus'), 'transparent_text'))->value = $vocabulary->description; $edit_items_array = $this->get_menu_type_data(); $edit_items = ''; foreach ($edit_items_array as $action => $menu_type) { $edit_items .= '<a class="modal_popup_form menu_button_dark" href="' . URL::get('admin', array('page' => 'menu_iframe', 'action' => $action, 'menu' => $vocabulary->id)) . "\">" . _t('Add %s', array($menu_type['label']), 'termmenus') . "</a>"; } if (!$vocabulary->is_empty()) { $form->append('tree', 'tree', $vocabulary->get_tree(), _t('Menu', 'termmenus')); $form->tree->config = array('itemcallback' => array($this, 'tree_item_callback')); // $form->tree->value = $vocabulary->get_root_terms(); // append other needed controls, if there are any. $form->append('static', 'buttons', _t("<div id='menu_item_button_container'>{$edit_items}</div>", 'termmenus')); $form->append('submit', 'save', _t('Apply Changes', 'termmenus')); } else { $form->append('static', 'buttons', _t("<div id='menu_item_button_container'>{$edit_items}</div>", 'termmenus')); } $delete_link = URL::get('admin', array('page' => 'menus', 'action' => 'delete_menu', 'menu' => $handler->handler_vars['menu'])); $form->append('static', 'deletebutton', _t("<a class='a_button' href='{$delete_link}'>Delete Menu</a>", 'termmenus')); $form->append(new FormControlHidden('menu', 'null:null'))->value = $handler->handler_vars['menu']; $form->on_success(array($this, 'rename_menu_form_save')); $form->properties['onsubmit'] = "return habari.menu_admin.submit_menu_update();"; $theme->page_content .= $form->get(); break; case 'create': $form = new FormUI('create_menu'); $form->append('text', 'menuname', 'null:null', _t('Menu Name', 'termmenus'), 'transparent_text')->add_validator('validate_required', _t('You must supply a valid menu name', 'termmenus'))->add_validator(array($this, 'validate_newvocab')); $form->append('text', 'description', 'null:null', _t('Description', 'termmenus'), 'transparent_text'); $form->append('submit', 'submit', _t('Create Menu', 'termmenus')); $form->on_success(array($this, 'add_menu_form_save')); $theme->page_content = $form->get(); break; case 'delete_menu': $menu_vocab = Vocabulary::get_by_id(intval($handler->handler_vars['menu'])); $menu_vocab->delete(); // log that it has been deleted? Session::notice(_t('Menu deleted.', 'termmenus')); // redirect to a blank menu creation form Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'create'))); break; case 'delete_term': $term = Term::get(intval($handler->handler_vars['term'])); $menu_vocab = $term->vocabulary_id; $term->delete(); // log that it has been deleted? Session::notice(_t('Item deleted.', 'termmenus')); Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $menu_vocab))); break; default: Utils::debug($_GET, $action); die; } $theme->display('menus_admin'); // End everything exit; }
/** * Prepare and display admin page * */ public function action_admin_theme_get_menus(AdminHandler $handler, Theme $theme) { $theme->page_content = ''; $action = isset($_GET['action']) ? $_GET['action'] : 'create'; switch ($action) { case 'edit': $vocabulary = Vocabulary::get_by_id(intval($handler->handler_vars['menu'])); if ($vocabulary == false) { $theme->page_content = '<h2>' . _t('Invalid Menu.'); // that's it, we're done. Maybe we show the list of menus instead? break; } $form = new FormUI('edit_menu'); $form->append(new FormControlText('menuname', 'null:null', _t('Name'), 'transparent_text'))->add_validator('validate_required', _t('You must supply a valid menu name'))->add_validator(array($this, 'validate_newvocab'))->value = $vocabulary->name; $form->append(new FormControlHidden('oldname', 'null:null'))->value = $vocabulary->name; $form->append(new FormControlText('description', 'null:null', _t('Description'), 'transparent_text'))->value = $vocabulary->description; $edit_items_array = $this->get_menu_type_data(); $edit_items = ''; foreach ($edit_items_array as $action => $menu_type) { $edit_items .= '<a class="modal_popup_form menu_button_dark" href="' . URL::get('admin', array('page' => 'menu_iframe', 'action' => $action, 'menu' => $vocabulary->id)) . "\">" . _t('Add %s', array($menu_type['label'])) . "</a>"; } if (!$vocabulary->is_empty()) { $form->append('tree', 'tree', $vocabulary->get_tree(), _t('Menu')); $form->tree->options = $vocabulary->get_tree(); $form->tree->config = array('itemcallback' => array($this, 'tree_item_callback')); // $form->tree->value = $vocabulary->get_root_terms(); // append other needed controls, if there are any. $form->append('static', 'buttons', '<div id="menu_item_button_container">' . $edit_items . '</div>'); $form->append('submit', 'save', _t('Apply Changes')); } else { $form->append('static', 'buttons', '<div id="menu_item_button_container">' . $edit_items . '</div>'); } $delete_link = URL::get('admin', Utils::WSSE(array('page' => 'menus', 'action' => 'delete_menu', 'menu' => $handler->handler_vars['menu']))); //$delete_link = URL::get( 'admin', array( 'page' => 'menus', 'action' => 'delete_menu', 'menu' => $handler->handler_vars[ 'menu' ] ) ); $form->append('static', 'deletebutton', '<a class="a_button" href="' . $delete_link . '">' . _t('Delete Menu') . '</a>'); $form->append(new FormControlHidden('menu', 'null:null'))->value = $handler->handler_vars['menu']; $form->on_success(array($this, 'rename_menu_form_save')); $form->properties['onsubmit'] = "return habari.menu_admin.submit_menu_update();"; $theme->page_content .= $form->get(); break; case 'create': $form = new FormUI('create_menu'); $form->append('text', 'menuname', 'null:null', _t('Menu Name'), 'transparent_text')->add_validator('validate_required', _t('You must supply a valid menu name'))->add_validator(array($this, 'validate_newvocab')); $form->append('text', 'description', 'null:null', _t('Description'), 'transparent_text'); $form->append('submit', 'submit', _t('Create Menu')); $form->on_success(array($this, 'add_menu_form_save')); $theme->page_content = $form->get(); break; case 'delete_menu': if (Utils::verify_wsse($_GET, true)) { $menu_vocab = Vocabulary::get_by_id(intval($handler->handler_vars['menu'])); // Delete blocks using this menu $at = Themes::get_active_data(true); $t = Themes::create(Themes::get_active()['name']); $i = 0; foreach ($at['areas'] as $area) { foreach ($t->get_blocks($area['name'], 0, $t) as $block) { if ($block->type == 'menu' && $block->menu_taxonomy == $handler->handler_vars['menu']) { $block->delete(); $i++; } } } Session::notice(sprintf(_n('%s block linking to this menu deleted.', '%s blocks linking to this menu deleted.', $i), $i)); $menu_vocab->delete(); // log that it has been deleted? Session::notice(_t('Menu deleted.')); // redirect to a blank menu creation form Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'create'))); } else { Session::notice(_t('Menu deletion failed - please try again.')); Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $handler->handler_vars['menu']))); } break; case 'delete_term': $term = Term::get(intval($handler->handler_vars['term'])); $menu_vocab = $term->vocabulary_id; if (Utils::verify_wsse($_GET, true)) { $term->delete(); // log that it has been deleted? Session::notice(_t('Item deleted.')); Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $menu_vocab))); } else { Session::notice(_t('Item deletion failed - please try again.')); Utils::redirect(URL::get('admin', array('page' => 'menus', 'action' => 'edit', 'menu' => $menu_vocab))); } break; default: Utils::debug($_GET, $action); die; } $theme->display('menus_admin'); // End everything exit; }
public function unsubscribe(Request $request) { $cookie_list = $request->cookie('list_joined'); $cid = $request->cookie('list_cid'); if ($cookie_list && $cid) { // now we can unsubscribe the user $member = ListMember::find($cid); $member->subscribed = 0; $member->save(); $list = MailList::find($cookie_list); $c1 = \Cookie::forget('list_joined'); $c2 = \Cookie::forget('list_cid'); return \Theme::display('lists.list-remove', ['list' => $list], array($c1, $c2)); } // look for get varibale if ($request->has('e')) { $member = ListMember::where('email', $request->e)->first(); $member->subscribed = 0; $member->save(); $list = MailList::find($member->list_id); // for good measure, unset cookie too. $c1 = \Cookie::forget('list_joined'); $c2 = \Cookie::forget('list_cid'); return \Theme::display('lists.list-remove', ['list' => $list], array($c1, $c2)); } // dfault page // @todo set up a way of searching email addresses and unsubsribing them. return \Theme::display('lists.list-subscriptions', []); }
/** * */ public static function Exec() { static::init(); Listing::parse(); Theme::display(); }
/** * Display the page **/ public function action_admin_theme_get_categories(AdminHandler $handler, Theme $theme) { $category_term = false; $parent_term = false; $parent_term_display = _t('None', 'simplecategories'); if (isset($_GET['action'])) { switch ($_GET['action']) { case 'delete': $term = $_GET['category']; $this->delete_category($term); break; case 'edit': $term = $_GET['category']; $category_term = $this->vocabulary->get_term((int) $term); if ($category_term) { $parent_term = $category_term->parent(); if ($parent_term) { $parent_term_display = $parent_term->term_display; } } break; } } if (isset($GET['category'])) { $term = $_GET['category']; $category_term = $this->vocabulary->get_term((int) $term); if ($category_term) { $parent_term = $category_term->parent(); if ($parent_term) { $parent_term_display = $parent_term->term_display; } } } $options = array(0 => _t('(none)', 'simplecategories')) + $this->vocabulary->get_options(); $form = new FormUI('simplecategories'); if ($category_term) { $category_id = $form->append('hidden', 'category_id')->value = $category_term->id; // send this id, for seeing what has changed $fieldset = $form->append('fieldset', '', sprintf(_t('Edit Category: <b>%1$s</b>', 'simplecategories'), $category_term->term_display)); } else { $fieldset = $form->append('fieldset', '', _t('Create a new Category', 'simplecategories')); } $category = $fieldset->append('text', 'category', 'null:null', _t('Category', 'simplecategories'), 'formcontrol_text'); $category->value = !$category_term ? '' : $category_term->term_display; $category->add_validator('validate_required'); $category->class = 'pct30'; $parent = $fieldset->append('select', 'parent', 'null:null', _t('Parent: <b>%1$s</b> Change Parent to:', array($parent_term_display), 'simplecategories'), $options, 'optionscontrol_select'); $parent->value = !$parent_term ? '' : $parent_term->id; // select the current parent $parent->class = 'pct50'; $save_button = $fieldset->append('submit', 'save', _t('Save', 'simplecategories')); $save_button->class = 'pct20 last'; // $cancelbtn = $form->append( 'button', 'btn', _t( 'Cancel', 'simplecategories' ) ); // $cancelbtn->id = 'btn'; // $cancelbtn->onclick = 'habari_ajax.get("' . URL::get( 'admin', 'page=categories' ) . '")' ; $cancelbtn = $form->append('static', 'btn', '<p id="btn" ><a class="button dashboardinfo" href="' . URL::get('admin', 'page=categories') . '">' . _t('Cancel', 'simplecategories') . "</a></p>\n"); if ($category_term) { //editing an existing category $form->on_success(array($this, 'formui_edit_submit')); } else { //new category $form->on_success(array($this, 'formui_create_submit')); } $theme->form = $form; $theme->all_categories = $this->vocabulary->get_tree(); $theme->display('categories'); // End everything exit; }
public function getEdit($id) { $user = User::find($id); return \Theme::display('users.edit', array('user' => $user)); }
public function frontEndCSS() { // get the css $fileData = \Theme::getCSS(); return \Theme::display('admin.css', ['file' => $fileData]); }
public function getEdit() { return \Theme::display('profile.edit', ['user' => \Auth::user()]); }
public function action_admin_theme_post_cronjob(AdminHandler $handler, Theme $theme) { // saving is handled by FormUI $cron = CronTab::get_cronjob((int) $handler->handler_vars['cron_id']); $theme->display('cronjob'); // this is stoopid, but exit so adminhandler doesn't complain exit; }
/** * @todo Removing initial newline shouldn't be necessary, find out what's causing it */ public function theme_route_display_tests(Theme $theme) { $url = $this->get_url('/index.php?c=symbolic&o=1&d=1'); $loaded_tests = false; try { $raw_xml = file_get_contents($url); $test_list = new \SimpleXMLElement(preg_replace("/^\n/", "", $raw_xml)); $loaded_tests = true; } catch (\Exception $e) { $output = $e->getMessage(); $output .= '<pre>' . Utils::htmlspecialchars($raw_xml) . '</pre>'; } if ($loaded_tests) { $output = ''; $unit_names = array(); foreach ($test_list->unit as $unit) { $unit_names[] = (string) $unit->attributes()->name; } $theme->unit_names = $unit_names; if (isset($_GET['run']) && isset($_GET['unit'])) { $dryrun = false; $unit = $_GET['unit']; if ($unit != 'all') { $url = '/index.php?c=symbolic&o=1&u=' . $unit; if (isset($_GET['test'])) { $test = $_GET['test']; $url = $url . '&t=' . $test; $theme->test = $test; } $url = $this->get_url($url); } else { $url = '/index.php?c=symbolic&o=1'; $url = $this->get_url($url); } if ($_GET['run'] == 'Dry Run') { $url .= '&d=1'; $dryrun = true; } } else { $dryrun = true; $url = $this->get_url('/index.php?c=symbolic&o=1&d=1'); } $results = preg_replace("/^\n/", "", file_get_contents($url)); $results_array = array(); $parsed_xml = true; $theme->symbolic_url = $url; $theme->direct_url = str_replace('c=symbolic', 'c=html', $url); try { $xmldata = file_get_contents($url); $results = @new \SimpleXMLElement(preg_replace("/^\n/", "", $xmldata)); } catch (\Exception $e) { if (strpos($xmldata, 'debugtoggle(') !== false) { $theme->error = var_export($e->getMessage(), true) . $xmldata; } else { $theme->error = var_export($e->getMessage(), true) . '<textarea style="width:100%;height: 20em;">' . htmlentities($xmldata) . '</textarea>'; } $parsed_xml = false; $theme->unit = $unit; } $theme->xmldata = $xmldata; if ($parsed_xml) { $dom = dom_import_simplexml($results)->ownerDocument; $dom->formatOutput = true; $theme->xmldata = $dom->saveXML(); $theme->connection_string = $results['connection_string']; foreach ($results->unit as $result) { $result_array = (array) $result->attributes(); $result_array = array_shift($result_array); $result_array['methods'] = array(); foreach ($result->method as $method) { $method_array = (array) $method; $output_array = array(); if (isset($method->output)) { // output is on, and output can appear whether passing or failing. foreach ($method->output as $outputz) { $output_array[] = $outputz; } } if (!isset($method->message)) { // no <message> means the method passed $method_result = 'Pass'; if ($dryrun) { $method_result = 'Dry Run'; } $result_array['methods'][] = array_merge(array_shift($method_array), array("result" => $method_result, "output" => implode(" ", $output_array))); } else { $message_array = array(); $result = (string) $method->message->attributes()->type; foreach ($method->message as $message) { $message_array[] = "{$message}" . ($result != "Fail" ? "" : "<br><em>" . basename($message->attributes()->file) . ":{$message->attributes()->line}</em>"); } $result_array['methods'][] = array_merge(array_shift($method_array), array("result" => $result, "messages" => implode("<br>", $message_array), "output" => implode(" ", $output_array))); } } $results_array[] = $result_array; } $theme->results = $results_array; $theme->unit = $unit; } } $theme->content = $output; $theme->display('header'); $theme->display('tests_admin'); $theme->display('footer'); exit; }
/** * Display a custom publish page for handled content types * * @param AdminHandler $handler The admin handler object * @param Theme $theme The admin theme object */ function action_admin_theme_get_publish($handler, $theme) { $handled = Options::get('cctypes_types'); if (isset($handler->handler_vars['id'])) { $post = Post::get(array('id' => $handler->handler_vars['id'], 'status' => Post::status('any'))); $ctype = Post::type_name($post->content_type); } else { if (isset($handler->handler_vars['content_type'])) { $ctype = $handler->handler_vars['content_type']; } } if (isset($ctype) && in_array($ctype, $handled)) { $template_name = 'admin_publish_' . $ctype; if ($theme->template_exists($template_name)) { $theme->display($template_name); exit; } } }
/** * Display the page **/ public function action_admin_theme_get_shelves(AdminHandler $handler, Theme $theme) { $all_terms = array(); $all_terms = $this->vocabulary->get_tree(); $one_shelf = ucfirst(Options::get('shelves__single', _t('shelf', 'shelves'))); if (!isset($_GET['shelf'])) { // create new shelf form $form = new FormUI('shelf-new'); $form->set_option('form_action', URL::get('admin', 'page=shelves')); $create_fieldset = $form->append('fieldset', '', _t('Create a new %s', array($one_shelf), 'shelves')); $shelf = $create_fieldset->append('text', 'shelf', 'null:null', $one_shelf, 'formcontrol_text'); $shelf->add_validator('validate_required'); $shelf->class = 'pct30'; $parent = $create_fieldset->append('select', 'parent', 'null:null', _t('Parent', 'shelves'), 'optionscontrol_select'); // $template doesn't work $parent->class = 'pct50'; $parent->options = array(); $parent->options[''] = ''; // top should be blank $right = array(); foreach ($all_terms as $term) { while (count($right) > 0 && $right[count($right) - 1] < $term->mptt_right) { array_pop($right); } $parent->options[$term->id] = str_repeat(' - ', count($right)) . $term->term_display; $right[] = $term->mptt_right; } $save_button = $create_fieldset->append('submit', 'save', _t('Create', 'shelves')); $save_button->class = 'pct20 last'; $cancelbtn = $form->append('button', 'btn', _t('Cancel', 'shelves')); $form->on_success(array($this, 'formui_create_submit')); } else { // edit form for existing shelf $which_shelf = $_GET['shelf']; $shelf_term = $this->vocabulary->get_term($which_shelf); if (!$shelf_term) { exit; } $parent_term = $shelf_term->parent(); if (!$parent_term) { $parent_term_display = _t('none', 'shelves'); } else { $parent_term_display = $parent_term->term_display; } $form = new FormUI('shelf-edit'); $form->set_option('form_action', URL::get('admin', 'page=shelves&shelf=' . $_GET['shelf'])); $shelf_id = $form->append('hidden', 'shelf_id')->value = $shelf_term->id; // send this id, for seeing what has changed $edit_fieldset = $form->append('fieldset', '', _t('Edit %1$s: <b>%2$s</b>', array($one_shelf, $shelf_term->term_display), 'shelves')); $shelf = $edit_fieldset->append('text', 'shelf', 'null:null', _t('Rename %s', array($one_shelf), 'shelves'), 'formcontrol_text'); $shelf->value = $shelf_term->term_display; $shelf->add_validator('validate_required'); $shelf->class = 'pct30'; $parent = $edit_fieldset->append('select', 'parent', 'null:null', sprintf(_t('Current Parent: <b>%1$s</b> Change Parent to:', 'shelves'), $parent_term_display), 'asdasdaoptionscontrol_select'); $parent->class = 'pct50'; $parent->options = array(); $parent->options[''] = ''; // top should be blank $right = array(); foreach ($shelf_term->not_descendants() as $term) { while (count($right) > 0 && $right[count($right) - 1] < $term->mptt_right) { array_pop($right); } $parent->options[$term->id] = str_repeat(' - ', count($right)) . $term->term_display; $right[] = $term->mptt_right; } $parent->value = !$parent_term ? '' : $parent_term->id; // select the current parent $save_button = $edit_fieldset->append('submit', 'save', _t('Edit', 'shelves')); $save_button->class = 'pct20 last'; $cancel_button = $form->append('submit', 'cancel_btn', _t('Cancel', 'shelves')); $form->on_success(array($this, 'formui_edit_submit')); } $theme->form = $form->get(); $theme->display('shelves'); // End everything exit; }