<?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
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 /** * 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');
<?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());