public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); $apps = array(); foreach (Typeframe::Registry()->pages() as $page) { if ($page->siteid() == Typeframe::CurrentPage()->siteid()) { if (strpos($page->uri(), '/admin/') !== false) { if ($page->allow()) { $apps[] = array('title' => $page->title(), 'icon' => $page->icon(), 'uri' => $page->uri()); } } } } $data['applications'] = $apps; if (class_exists('Model_Site')) { $sites = new Model_Site(); if (Typeframe::User()->get('usergroupid') != TYPEF_ADMIN_USERGROUPID) { $sites->innerJoin('perm', 'Model_User_Site', 'id = perm.siteid'); $sites->where('perm.userid = ?', Typeframe::User()->get('userid')); $primary = new Model_User_Site(); $primary->where('userid = ?', Typeframe::User()->get('userid')); $primary->where('siteid = ?', 0); $data['admin_primary'] = $primary->count() > 0; } else { $data['admin_primary'] = 1; } $data['sites'] = $sites; } $data->sortNodes(array('applications', 'title')); if (defined('TYPEF_HOST')) { $data['primary_host'] = TYPEF_HOST; } parent::output($data, $stream); }
private static function _AtResponse(Typeframe_Response $response) { $settings = $response->page()->settings(); if (!empty($settings['skin'])) { return $settings['skin']; } $uri = $response->applicationUri(); $admin_root = TYPEF_WEB_DIR . '/admin'; if (Typeframe::CurrentPage()->siteid() != 0) { $site = Model_Site::Get(Typeframe::CurrentPage()->siteid()); if ($site['directory']) { $admin_root = TYPEF_WEB_DIR . '/' . $site['directory'] . '/admin'; } } if ($uri == $admin_root || substr($uri, 0, strlen($admin_root . '/')) == $admin_root . '/') { if (TYPEF_USE_MOBILE_SKINS && self::_IsMobile()) { return TYPEF_MOBILE_ADMIN_SKIN; } if (TYPEF_ADMIN_SKIN) { return TYPEF_ADMIN_SKIN; } } if (TYPEF_USE_MOBILE_SKINS && self::_IsMobile()) { return TYPEF_MOBILE_SITE_SKIN; } return TYPEF_SITE_SKIN ? TYPEF_SITE_SKIN : 'default'; }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $this->pluginTemplate = "/downloads/downloads.plug.html"; $data = $data->fork(); $downloads = new Model_Download_File(); $downloads->where('siteid = ?', Typeframe::CurrentPage()->siteid()); $data['downloads'] = $downloads; parent::output($data, $stream); }
public function admin(Pagemill_Data $data, Pagemill_Stream $stream) { $this->adminTemplate = '/admin/mailform/settings.plug.html'; $data = $data->fork(); $data->setArray($this->attributes()); $mailforms = new Model_Mailform(); $mailforms->where('siteid = ?', Typeframe::CurrentPage()->siteid()); $data->set('mailforms', $mailforms); parent::admin($data, $stream); }
/** * Get the cached page content. * @return array */ public static function Cache() { static $cached_content = null; if (is_null($cached_content)) { if (Typeframe::CurrentPage()->page()->pageid()) { $page = Model_Content_Page::Get(Typeframe::CurrentPage()->page()->pageid()); $cached_content = $page['content']; } } return $cached_content; }
public function output(Pagemill_Data $data, Pagemill_Stream $stream) { $data = $data->fork(); if (!empty($this->attributes['menuplugid'])) { $menuplugid = $this->attributes['menuplugid']; $db = Typeframe::Database(); $base = substr(Typeframe::CurrentPage()->uri(), STRLEN(TYPEF_WEB_DIR)); if ($base == '') { $base = '/'; } $search = new Model_Nav(); $search->where('plugid = ?', $menuplugid); $search->where('url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR url = ? OR pageid = ?', "~{$base}", "~{$base}/", "/{$base}", "/{$base}/", TYPEF_WEB_DIR . $base, TYPEF_WEB_DIR . $base . '/', Typeframe::CurrentPage()->pageid()); foreach ($search->select() as $current) { $current['url'] = $this->_convertUrl($current['url']); $data->set('current', $current); $parentid = $current['parent']; $siblings = new Model_Nav(); $siblings->where('plugid = ?', $menuplugid); $siblings->where('parent = ?', $parentid); $siblings->order('sortnum'); $data['siblings'] = $siblings; /*$sibArray = array(); foreach ($siblings->select() as $sib) { $sib['url'] = $this->_convertUrl($sib['url']); $sibArray[] = $sib; } $data['siblings'] = $sibArray;*/ if (!empty($this->attributes['showparent'])) { $parent = $db->execute('SELECT * FROM #__nav WHERE itemid = ' . $parentid); foreach ($parent as $par) { $par['url'] = $this->_convertUrl($par['url']); $data->set('parent', $par); } } if (!empty($this->attributes['showchildren'])) { $childArray = array(); $children = $db->execute('SELECT * FROM #__nav WHERE plugid = ' . $menuplugid . ' AND parent = ' . $current['itemid'] . ' ORDER BY sortnum'); foreach ($children as $chi) { $chi['url'] = $this->_convertUrl($chi['url']); $childArray[] = $chi; } $data['children'] = $childArray; } } } $this->pluginTemplate = "navigation/submenu.plug.html"; parent::output($data, $stream); }
public function output(\Pagemill_Data $data, \Pagemill_Stream $stream) { $data = $data->fork(); $url = Typeframe::CurrentPage()->uri(); if (substr($url, -1) == '/') { $url = substr($url, 0, -1); } $dirs = explode('/', substr($url, strlen(TYPEF_WEB_DIR))); $this->pluginTemplate = '/breadcrumbs/breadcrumbs.plug.html'; $data['breadcrumbs'] = array(); $currentUrl = TYPEF_WEB_DIR; $start = $data->parseVariables(Typeframe_Attribute_Url::ConvertShortUrlToExpression($this->getAttribute('start'))); while (count($dirs) > 0) { $currentUrl .= '/' . array_shift($dirs); $currentUrl = preg_replace('/\\/+/', '/', $currentUrl); if ($start && strpos($currentUrl, $start) === false) { continue; } if (isset($_SESSION['breadcrumbs'][$currentUrl])) { $bc = $_SESSION['breadcrumbs'][$currentUrl]; $bc['url'] = $currentUrl . ($bc['query'] ? '?' . $bc['query'] : ''); $data['breadcrumbs'][] = $bc; } else { $response = Typeframe::Registry()->responseAt($currentUrl); if ($currentUrl == $response->page()->uri()) { if ($response->application()->name() != '403' && $response->application()->name() != '404') { $settings = $response->page()->settings(); if (!empty($settings['nickname'])) { $title = $settings['nickname']; } else { $title = $response->page()->title(); } $bc = array('title' => $title, 'query' => ''); $_SESSION['breadcrumbs'][$currentUrl] = $bc; $bc['url'] = $currentUrl; $data['breadcrumbs'][] = $bc; } } } } parent::output($data, $stream); return; }
public static function GetCategoryId($from_settings = false) { // get categoryid from request, if any $categoryid = $from_settings ? '' : trim(@$_REQUEST['categoryid']); if (0 == strlen($categoryid)) { // none give; try loading from settings $settings = Typeframe::CurrentPage()->settings(); $categoryid = @$settings['categoryid']; // if none set, display all by default if (is_null($categoryid)) { return array(0); } // if it's an array if (is_array($categoryid)) { // and contains all case, return all if (in_array(0, $categoryid)) { return array(0); } // if has more than one value, convert all to ints if (count($categoryid) > 0) { $result = array(); foreach ($categoryid as $value) { if (ctype_digit($value)) { $result[] = intval($value); } } return $result; } // otherwise, convert single value to int return intval($categoryid[0]); } // otherwise, convert single value to int return intval($categoryid); } // integer category id given if (ctype_digit($categoryid)) { return intval($categoryid); } // none of the above return null; }
<?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 $mailform['mailformname'] = $_POST['mailformname']; $mailform['message'] = $_POST['message']; $mailform['response'] = $_POST['response']; $mailform['subject'] = $_POST['subject']; $mailform['replyto'] = $_POST['replyto']; $mailform['redirect'] = $_POST['redirect']; $mailform['template'] = $_POST['template']; $recipients = array(); for ($i = 0; $i < count($_POST['recipients']['email']); $i++) { if (!empty($_POST['recipients']['email'][$i])) { $recipients[] = array('email' => $_POST['recipients']['email'][$i], 'name' => $_POST['recipients']['name'][$i], 'when' => $_POST['recipients']['when'][$i], 'fieldname' => $_POST['recipients']['fieldname'][$i], 'fieldvalue' => $_POST['recipients']['fieldvalue'][$i]); } } $mailform['recipients'] = $recipients; $formfields = array(); for ($i = 0; $i < count($_POST['fields']['name']); $i++) { if (!empty($_POST['fields']['name'][$i])) { $formfields[] = array('name' => $_POST['fields']['name'][$i], 'class' => $_POST['fields']['class'][$i], 'type' => $_POST['fields']['type'][$i], 'values' => $_POST['fields']['values'][$i], 'required' => $_POST['fields']['required'][$i]); } } $mailform['captcha'] = !empty($_POST['captcha']) ? 1 : 0; $mailform['formfields'] = $formfields; $mailform->save(); Typeframe::Redirect('Mailform saved.', Typeframe::CurrentPage()->applicationUri());
/** * Log a user action to the database. * @param string $action. * @param string $fulldesc The full description of the event [optional]. */ public static function Log($action, $fulldesc = false) { if (!$fulldesc) { $fulldesc = $action; } // Also addin the source URL, as that may change and reveal important information. if (isset($_SERVER['HTTP_HOST'])) { $fulldesc .= "\n" . 'Source URL: ' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; if (isset($_SERVER['HTTP_REFERER'])) { $fulldesc .= "\n" . 'Referrer URL: ' . $_SERVER['HTTP_REFERER']; } } else { $fulldesc .= "\nN/a"; } $log = Model_Log::Create(); $log['userid'] = Typeframe::User()->get('userid'); $log['ipaddress'] = @$_SERVER['REMOTED_ADDR']; $log['package'] = Typeframe::CurrentPage() ? Typeframe::CurrentPage()->application()->package() : ''; $log['application'] = Typeframe::CurrentPage() ? Typeframe::CurrentPage()->application()->name() : ''; $log['action'] = $action; $log['logdate'] = Typeframe::Now(); $log['fulldesc'] = $fulldesc; $log->save(); }
public static function ProcessRules($string) { $show = false; $rules = explode(';', $string); $countrules = count($rules); // Now I can do the check to see if there are no rules. if ($countrules <= 0) { $show = true; } foreach ($rules as $r) { list($type, $code) = explode(':', $r); $not = false; if (substr($type, 0, 1) == '!') { $type = substr($type, 1); $not = true; } switch ($type) { case 'pid': if (Typeframe::CurrentPage()->page()->pageid() == $code) { if ($not) { $show = false; return false; } else { $show = true; } } break; case 'url': if ($code == '*') { if ($not) { $show = false; return false; } else { $show = true; continue; } } if (substr($code, 0, 2) == '//') { $code = TYPEF_WEB_DIR . substr($code, 1); } if (($pos = strpos($code, '*')) !== false) { if (substr(Typeframe::CurrentPage()->uri(), 0, $pos) == substr($code, 0, $pos)) { if ($not) { $show = false; return false; } else { $show = true; } } } if (Typeframe::CurrentPage()->uri() == $code) { if ($not) { $show = false; return false; } else { $show = true; } } break; } // switch($type) } // foreach ($rules as $r) return $show; }
<?php $file = isset($_REQUEST['file']) ? $_REQUEST['file'] : ''; if ($file && file_exists(TYPEF_DIR . $file) && is_file(TYPEF_DIR . $file)) { header('Content-type: text/css'); $dir = dirname($file); $md5 = md5($file) . '.css'; $dst = TYPEF_DIR . '/files/cache/lessphp/' . $md5; lessc::ccompile(TYPEF_DIR . $file, $dst); $css = SimpleCss::LoadFile($dst, TYPEF_WEB_DIR . $dir); $code = $css->toString(); preg_match_all('/url\\(\\"([\\w\\W\\s\\S]*?)"\\)/', $code, $matches); if (isset($matches[1])) { foreach ($matches[1] as $url) { $url = Typeframe_Attribute_Url::ConvertShortUrlToExpression($url); $url = Typeframe::Pagemill()->data()->parseVariables($url); $code = str_replace($matches[1], $url, $code); } } echo $code; exit; } else { http_response_code(404); Typeframe::SetPageTemplate('/404.html'); Typeframe::CurrentPage()->stop(); }
<?php /* 29 december 2010: cleanup while trying to add status field to typef_news table; rewrote to use news tag class 3 january 2011: DAOFactory, not DAO_Factory; setCategoryId now static 28 march 2011: merged in code from HL 29 march 2011: added page title, header */ // define some handy shortcuts to save typing $settings = Typeframe::CurrentPage()->settings(); // create news tag object $tags = News_Tag::DAOFactory(); // inner join on the news article table $tags->select()->innerJoin('#__news', '#__news.newsid = #__news_tag.newsid'); // add the count of news articles to the result $tags->select()->field('COUNT(#__news_tag.newsid) AS articles'); // limit to a particular category id News::SetCategoryId($tags, @$settings['categoryid']); // group and sort by tag name $tags->select()->group('tag'); $tags->select()->order('tag'); // add tags to template $pm->setVariable('tags', $tags); // add page title and header to template $title = News::GetTitle(); $pm->setVariable('page_title', $title); $pm->setVariable('page_header', $title);
private function _executeApplicationCode() { static $executed = false; if (!$executed) { $executed = true; // Execute triggers $currentPath = $this->path(); $this->_executeTriggers('before'); if (Typeframe::CurrentPage()->stopped()) { return; } Typeframe_Page::_IncludeController(Typeframe::CurrentPage()->controller()); if (Typeframe::CurrentPage()->stopped()) { return; } $this->_executeTriggers('after'); } else { trigger_error('Applications can only be executed once'); } }
<?php $mailform = Model_Mailform::Get($_REQUEST['mailformid']); if ($mailform->exists()) { include 'form.inc.php'; $log = new Model_Mailform_Log(); $log->where('mailformid = ?', $_REQUEST['mailformid']); /*if ($log->count()) { Typeframe::Redirect( 'This mailform has submissions. If you want to change the fields, it is recommended that you create a new mailform instead.', Typeframe::CurrentPage()->applicationUri(), -1); return; }*/ $pm->setVariable('mailform', $mailform); if ($_SERVER['REQUEST_METHOD'] == 'POST') { require_once 'update.inc.php'; Typeframe::Redirect('Mailform updated.', Typeframe::CurrentPage()->applicationUri()); } } else { Typeframe::Redirect('Invalid mailform specified.', Typeframe::CurrentPage()->applicationUri()); }
function skin_path($path) { $path = (string) $path; $uri = Typeframe::CurrentPage()->uri(); if (substr($path, 0, 1) != '/') { $path = '/' . $path; } if (file_exists(TYPEF_DIR . '/skins/' . Typeframe_Skin::Current() . $path)) { return TYPEF_ROOT_WEB_DIR . '/skins/' . Typeframe_Skin::Current() . $path; /*} else if (file_exists(TYPEF_DIR . '/skins/default' . $path)) { return TYPEF_ROOT_WEB_DIR . '/skins/default' . $path; } else if (file_exists(TYPEF_DIR . '/files/static' . $path)) { return TYPEF_ROOT_WEB_DIR . '/files/static' . $path; } else { // TODO: This might not be the best default. Should it trigger an error? return TYPEF_ROOT_WEB_DIR . $path; }*/ } else { if (Typeframe_Skin::Current() != TYPEF_SITE_SKIN && $uri != TYPEF_WEB_DIR . '/admin' && substr($uri, 0, strlen(TYPEF_WEB_DIR . '/admin/')) != TYPEF_WEB_DIR . '/admin/') { if (file_exists(TYPEF_DIR . '/skins/' . TYPEF_SITE_SKIN . $path)) { return TYPEF_ROOT_WEB_DIR . '/skins/' . TYPEF_SITE_SKIN . $path; } } else { return TYPEF_ROOT_WEB_DIR . '/skins/default' . $path; } } }
public static function GetTitle() { $app = Typeframe::CurrentPage()->application(); $page = Model_Page::Get($app->pageid()); return $page->exists() && strlen($page->get('nickname')) > 0 ? $page->get('nickname') : $app->title(); }
<?php $usergroup = Model_Usergroup::Get($_REQUEST['usergroupid']); if ($usergroup->exists()) { if ($_SERVER['REQUEST_METHOD'] == 'POST') { include 'update.inc.php'; Typeframe::Redirect('User group updated.', Typeframe::CurrentPage()->applicationUri() . '/groups'); } else { $pm->setVariable('usergroup', $usergroup); $admin = new BaseModel_UsergroupAdmin(); $admin->where('usergroupid = ?', $usergroup['usergroupid']); $apps = array(); foreach ($admin->select() as $a) { $apps[] = $a['application']; } $pm->setVariable('admin_applications', $apps); include 'form.inc.php'; } } else { }
/** * Get URL metadata for a URL. * @param string $url The URL. If null, use the current page. * @param boolean $create Create a new record if the URL is valid. * @param string $newLabel The label for the URL if it doesn't exist. * @return Dbi_Record The URL metadata record. */ public static function GetUrl($url = null, $create = true, $newLabel = '') { if (is_null($url)) { //$url = Typeframe::CurrentPage()->uri(); //$app = Typeframe::CurrentPage()->application(); $url = Typeframe::CurrentPage()->uri(); if (substr($url, 0, -1) == '/') { $url = substr($url, -1); } $response = Typeframe::CurrentPage(); } else { $url = parse_url($url, PHP_URL_PATH); if (substr($url, 0, -1) == '/') { $url = substr($url, -1); } $url = preg_replace('/\\/+/', '/', $url); //$app = Typeframe::Registry()->applicationAt($url); $response = Typeframe::Registry()->responseAt($url); } $app = $response->application(); // Return a blank (nonexistent) Dbi_Record for invalid URLs if (!$app) { return Model_UrlMeta::Create(); } $model = new Model_UrlMeta(); $model->where('pageid = ?', $response->pageid()); if ($response->pageid()) { $pathinfo = substr($url, strlen($response->applicationUri())); } else { $pathinfo = substr($response->applicationUri(), strlen(TYPEF_WEB_DIR)); } if ($pathinfo == '/') { $pathinfo = ''; } $model->where('pathinfo = ?', $pathinfo); $urlmeta = $model->getFirst(); if (!$urlmeta->exists() && $create) { // Record does not exist. Generate a label and save it. $urlmeta['pageid'] = $response->pageid(); $urlmeta['pathinfo'] = $pathinfo; if (!$newLabel) { // We need to save the metadata before we request the URL by proxy. Otherwise it's hammers all the way down. $urlmeta->save(); // Create a label for the URL metadata $html = Typeframe::GetByProxy($url); if (!$html) { return Model_UrlMeta::Create(); } else { $xml = @Pagemill_SimpleXmlElement::LoadString($html); if ($xml) { $selector = URLMETA_LABEL_SELECTOR ? URLMETA_LABEL_SELECTOR : 'title'; $parts = explode(',', $selector); foreach ($parts as $part) { if (trim($part)) { $elements = $xml->select(trim($part)); if ($elements) { $urlmeta['label'] = trim($elements[0]->innerXml()); break; } } } } } if (!$urlmeta['label']) { $urlmeta['label'] = $app->title(); } } else { $urlmeta['label'] = $newLabel; } $urlmeta->save(); } return $urlmeta; }
$template = TYPEF_SOURCE_DIR . '/templates/content/' . (!empty($settings['template']) ? $settings['template'] : 'generic.html'); if (!file_exists($template)) { $page->set('dead_template', $settings['template']); $template = (TYPEF_SOURCE_DIR . '/templates/content/generic.html'); } $elements = Insertable::ElementsFrom($template); $groups = Insertable::GroupsFrom($template); if ((count($elements) > 0) || (count($groups) > 0)) { $garray = array(); foreach ($groups as $group) { if (empty($group['admin']) || (Typeframe::User()->get('usergroupid') == TYPEF_ADMIN_USERGROUPID) || inGroup($group['admin'])) $garray[] = $group; } $page->set('groups', $garray); $pm->addLoop('pages', $page->getAsArray()); } }*/ $pm->setVariable('pages', $pages); // add plugins $plugs = new Model_Plug(); //$plugs->where('plug = ?', 'Content'); $plugs->where('siteid = ?', Typeframe::CurrentPage()->siteid()); $plugs->order('name'); $pm->setVariable('plugins', $plugs); /*$all_pages = new Model_Page(); $all_pages->where('siteid = ?', Typeframe::CurrentPage()->siteid()); $all_pages->order('nickname, uri'); $pm->setVariable('all_pages', $all_pages);*/
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $master = Model_Site_Master::Create(); $master->setArray($_POST, false); $master->save(); Typeframe::Redirect('Master created.', Typeframe::CurrentPage()->applicationUri() . '/masters/pages?masterid=' . $master['id']); }
<?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 /** * Typeframe News application * * admin-side index controller */ // get sorting options list($sort_options, $sort, $order) = News::GetAdminSortingOptions(); // set sorting in template $pm->setVariable('sort_options', $sort_options); $pm->setVariable('sort', $sort); if (!empty($_REQUEST['pageid'])) { $page = Model_Page::Get($_REQUEST['pageid']); if (!$page->exists() || $page['application'] != 'News' && $page['application'] != 'News RSS') { Typeframe::Redirect('Invalid page specified.', Typeframe::CurrentPage()->applicationUri(), 1); return; } $pm->setVariable('currentpage', $page); } $newspages = new Model_Page(); $newspages->where('application = ?', 'News'); $pm->setVariable('newspages', $newspages); $articles = new Model_News_Article(); $total = $articles->count(); if (!empty($_REQUEST['status'])) { $articles->where('status = ?', $_REQUEST['status']); } $articles->order($order); // set up pagination $page = @$_REQUEST['page'] && ctype_digit($_REQUEST['page']) ? intval($_REQUEST['page']) : 1;
<?php if ($_SERVER['REQUEST_METHOD'] == 'POST') { $mailform = Model_Mailform::Get($_POST['mailformid']); if ($mailform->exists()) { $mailform->delete(); Typeframe::Redirect('Mailform deleted.', Typeframe::CurrentPage()->applicationUri()); return; } } Typeframe::Redirect('Nothing to do.', Typeframe::CurrentPage()->applicationUri());
<?php Typeframe::CurrentPage()->registerCallback(Typeframe::CurrentPage()->controllerPath(), function () { if (http_response_code() == 404) { $redirects = new Model_Redirect(); $redirects->where('original = ? OR original = ? OR original = ?', Typeframe::CurrentPage()->uri(), Typeframe::CurrentPage()->uri() . '/', '~' . substr(Typeframe::CurrentPage()->uri(), strlen(TYPEF_WEB_DIR))); $redirect = $redirects->getFirst(); if ($redirect->exists()) { Typeframe::Redirect('Redirecting to ' . $redirect['destination'] . '...', $redirect['destination'], 0, true, 301); } } });
<?php /* 29 december 2010: cleanup while trying to add status field to typef_news table; rewrote to use news categories class 3 january 2011: DAOFactory, not DAO_Factory; setCategoryId now static 28 march 2011: merged in HL code 29 march 2011: added page title, header */ // define some handy shortcuts to save typing $settings = Typeframe::CurrentPage()->settings(); if (Typeframe::CurrentPage()->pathInfo()) { Typeframe::IncludeScript('/news/categories/view.php'); return; } if (is_array($settings['categoryid']) && !in_array(0, $settings['categoryid']) && 1 == count($settings['categoryid'])) { Typeframe::Redirect('Redirecting to category listing...', Typeframe::CurrentPage()->applicationUri() . 'categories/' . $settings['categoryid'][0]); return; } // create news category object $categories = News_Category::DAOFactory(); // limit to a particular category id News::SetCategoryId($categories, @$settings['categoryid']); // add categories to template $pm->setVariable('categories', $categories); // add page title and header to template $title = News::GetTitle(); $pm->setVariable('page_title', $title); $pm->setVariable('page_header', $title);
<?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 if ($_SERVER['REQUEST_METHOD'] == 'POST') { Model_Redirect::Delete($_POST['id']); Typeframe::Redirect('Redirect deleted.', Typeframe::CurrentPage()->applicationUri()); }
<?php $form = new Form_Handler_User(!$user->exists() || !empty($_POST['password']) ? true : false); $form->validate(); $errors = $form->errors(); if ($errors) { $pm->setVariable('errors', $errors); $pm->setVariable('user', $form->input()); } else { $user->setArray($_POST, false); $user['password'] = $_POST['password']; $user->save(); if (defined('TYPEF_HOST')) { $sites = Model_User_Site::ForUserId($user['userid']); $sites->deleteQuery(); if (!empty($_POST['admin_siteid'])) { foreach ($_POST['admin_siteid'] as $siteid) { $site = Model_User_Site::Create(); $site['userid'] = $user['userid']; $site['siteid'] = $siteid; $site->save(); } } } Typeframe::Redirect('User saved.', Typeframe::CurrentPage()->applicationUri()); }