<?php /** * Typeframe Content application * * admin-side plug controller */ Plugin_Breadcrumbs::Add('Edit Plugin'); // save typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // validate plug id (must be 'Content' plug) $plugid = @$_REQUEST['plugid']; $plug = Model_Plug::Get($plugid); //if (!$plug->exists() || ('Content' != $plug->get('plug'))) if (!$plug->exists()) { Typeframe::Redirect('Invalid plugin.', $typef_app_dir, -1); return; } // get template from settings; expand to its full value $settings = $plug['settings']; $template = isset($settings['template']) ? $settings['template'] : 'generic.plug.html'; $full_template = TYPEF_SOURCE_DIR . '/templates/content/' . $template; // cannot edit content if template does not exist if (!file_exists($full_template)) { Typeframe::Redirect("Unable to find plugin template ({$template}).", $typef_app_dir, -1); return; } // load inserts and groups for template $inserts = Insertable::ElementsFrom($full_template); $groups = Insertable::GroupsFrom($full_template); // get revision id, if any
<?php $site = Model_Site::Get($_REQUEST['id']); if ($site->exists()) { require_once 'options.inc.php'; $pm->setVariable('site', $site); if ($_SERVER['REQUEST_METHOD'] == 'POST') { include 'update.inc.php'; Typeframe::Redirect('Site updated.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri())); } } else { Typeframe::Redirect('Invalid site specified.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri())); }
<?php $site = Model_Site::Get($_REQUEST['id']); if ($site->exists()) { $pm->setVariable('site', $site); if ($_SERVER['REQUEST_METHOD'] == 'POST') { Model_Site::Delete($_POST['id']); Typeframe::Redirect('Site deleted.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->applicationUri())); } } else { Typeframe::Redirect('Invalid site specified.', Typeframe::CurrentPage()->applicationUri()); }
<?php /** * Create a new plugin. */ Plugin_Breadcrumbs::Add('Add'); // save typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // process form if ('POST' == $_SERVER['REQUEST_METHOD']) { $plug = Model_Plug::Create(); $plug->set('plug', $_POST['plug']); //$plug->set('settings', json_encode((isset($_POST['settings']) && is_array($_POST['settings'])) ? $_POST['settings'] : array())); $plug->set('settings', isset($_POST['settings']) && is_array($_POST['settings']) ? $_POST['settings'] : array()); $plug['siteid'] = Typeframe::CurrentPage()->siteid(); $plug->save(); // done $skin = isset($_REQUEST['skin']) ? "&skin={$_REQUEST['skin']}" : ''; Typeframe::Redirect('Plugin created.', "{$typef_app_dir}/edit?plugid=" . $plug->get('plugid') . $skin); return; } // load plugins; add to template; sort by name foreach (Typeframe::Registry()->plugins() as $plugin) { $pm->addLoop('plugins', array('name' => $plugin->name())); } $pm->sortLoop('plugins', 'name');
/** * Typeframe News application * * admin-side delete controller */ // save some typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // if not posting, bounce out of here if ('POST' != $_SERVER['REQUEST_METHOD']) { Typeframe::Redirect('Nothing to do.', $typef_app_dir); return; } // create news article object from given id $newsid = @$_POST['newsid']; $article = Model_News_Article::Get($newsid); // news article must exist to proceed if (!$article->exists()) { Typeframe::Redirect('Invalid article id specified.', $typef_app_dir); return; } // current user must be the author of the article or an admin if (Typeframe::User()->get('userid') != $article['authorid'] && Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) { Typeframe::Redirect("You cannot delete other users' news items.", $typef_app_dir, 1, false); return; } // perform the delete $article->delete(); // done Typeframe::Redirect('Article has been deleted.', Plugin_Breadcrumbs::SavedState($typef_app_dir));
<?php /* Comment admin delete controller 24 march 2011: cleanedup 29 march 2011: modified to use Comment class */ // back link $back = Plugin_Breadcrumbs::SavedState(TYPEF_WEB_DIR . '/admin/comments'); // can only process POSTs if ('POST' != $_SERVER['REQUEST_METHOD']) { Typeframe::Redirect('Nothing to do.', $back); return; } // delete given comment $comment = Model_Comment::Get(@$_POST['commentid']); if ($comment->exists()) { $comment->delete(); } // done Typeframe::Redirect('Comment deleted.', $back);
<?php $comment = Model_Comment::Get($_REQUEST['commentid']); if ($comment->exists()) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { $state = $comment['approved'] ? 'unapproved' : 'approved'; $comment['approved'] = !$comment['approved']; $comment->save(); Typeframe::Redirect("Comment {$state}.", Plugin_Breadcrumbs::SavedState(TYPEF_WEB_DIR . '/admin/comments')); } $pm->setVariable('comment', $comment); } else { Typeframe::Redirect("Invalid comment specified.", Plugin_Breadcrumbs::SavedState(TYPEF_WEB_DIR . '/admin/comments'), 1); }
/** * Set the appropriate breadcrumb to the system breadcrumbs. */ private function set_breadcrumbs($plugid, $nav_item = null) { //set up root breadcrumb Plugin_Breadcrumbs::AddBreadcrumb('Navigation Root', TYPEF_WEB_DIR . '/admin/plugins/edit?plugid=' . $plugid); if ($nav_item) { $tree = $this->get_tree_down($nav_item); foreach ($tree as $el) { Plugin_Breadcrumbs::AddBreadcrumb($el['label'], TYPEF_WEB_DIR . '/admin/plugins/edit?plugid=' . $plugid . '&parentid=' . $el['itemid']); } } }
if ($path) { // Get the article by encoded title $articles->where('encodedtitle = ?', $path); } else { // Get the article by news ID if possible if (isset($_REQUEST['newsid'])) { $articles->where('newsid = ?', $_REQUEST['newsid']); $redirect = true; } else { Typeframe::Redirect('No news article was specified.', $typef_app_dir, 1, false); return; } } if (isset($settings['categoryid']) && is_array($settings['categoryid']) && !in_array(0, $settings['categoryid'])) { $articles->where('categoryid IN ?', $settings['categoryid']); } $articles->where('pubdate <= ?', Typeframe::Now()); $articles->where('expdate = ? OR expdate > ? OR expdate IS NULL', '0000-00-00 00:00:00', Typeframe::Now()); $articles->where('status = ?', 'published'); $article = $articles->getFirst(); if (!$article->exists()) { http_response_code(404); Typeframe::Redirect('Invalid article specified.', $typef_app_dir, 1, false); return; } if ($redirect) { Typeframe::Redirect('Redirecting to article...', $typef_app_dir . '/' . $article['encodedtitle']); return; } Plugin_Breadcrumbs::Add($article['title']); $pm->setVariable('news', $article);
<?php /** * Typeframe Content application * * admin-side page controller */ Plugin_Breadcrumbs::Add('Edit Page'); // save typing below $typef_app_dir = Typeframe::CurrentPage()->applicationUri(); // validate page id (must be 'Content' page) $pageid = @$_REQUEST['pageid']; $page = Model_Page::Get($pageid); //if (!$page->exists() || ('Content' != $page->get('application')) || $page['siteid'] != Typeframe::CurrentPage()->siteid()) if (!$page->exists() || $page['siteid'] != Typeframe::CurrentPage()->siteid()) { Typeframe::Redirect('Invalid page.', $typef_app_dir, -1); return; } if ($page['application'] == 'Content') { // get template from settings; expand to its full value $settings = $page['settings']; $template = @$settings['template']; if (!$template) { $template = 'generic.html'; } $template = "/content/{$template}"; $full_template = TYPEF_SOURCE_DIR . "/templates{$template}"; } else { $response = Typeframe_Response::At(TYPEF_WEB_DIR . $page['uri']); $template = $response->getPageTemplate(); $full_template = Typeframe_Skin::TemplatePath($template, $response->applicationUri());
<?php include 'form.inc.php'; if ($_SERVER['REQUEST_METHOD'] == 'POST') { $article = Model_News_Article::Create(); include 'update.inc.php'; if (!$article->dirty()) { Typeframe::Redirect('Article created.', Plugin_Breadcrumbs::SavedState(Typeframe::CurrentPage()->page()->uri())); } }