if (isset($_GET['id']) && is_numeric($_GET['id'])) { $assetID = (int) $_GET['id']; $Asset = $Assets->find($assetID); if ($Asset) { if (!$Asset->is_image()) { $FieldTag->set('type', 'file'); } } } else { if (!$CurrentUser->has_priv('assets.create')) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/assets/'); } $assetID = false; $Asset = false; } $Form = new PerchForm('edit'); $req = array(); $req['resourceTitle'] = "Required"; $Form->set_required($req); if ($Form->posted() && $Form->validate()) { /* if (isset($_POST['image_remove']) && $_POST['image_remove']=='1') { $Asset->delete(); PerchUtil::redirect() } */ $created = false; $postvars = array('resourceTitle', 'resourceInLibrary', 'resourceBucket'); $data = $Form->receive($postvars); if (isset($data['resourceBucket'])) { $FieldTag->set('bucket', $data['resourceBucket']);
<?php if (!$CurrentUser->has_priv('categories.delete')) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } $Categories = new PerchCategories_Categories(); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $catID = (int) $_GET['id']; $Category = $Categories->find($catID); } if (!$Category || !is_object($Category)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/'); } /* --------- Delete Form ----------- */ $Form = new PerchForm('delete'); if ($Form->posted() && $Form->validate()) { $Category->delete(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/apps/categories/sets/?id=' . $Category->setID(); exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/categories/sets/?id=' . $Category->setID()); } }
<?php if (isset($_GET['id']) && is_numeric($_GET['id'])) { $region_id = (int) $_GET['id']; $item_id = (int) $_GET['itm']; $Regions = new PerchContent_Regions(); $Region = $Regions->find($region_id); $Pages = new PerchContent_Pages(); $Page = $Pages->find($Region->pageID()); } if (!$Region || !is_object($Region)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content'); } // set the current user $Region->set_current_user($CurrentUser->id()); /* --------- Delete Form ----------- */ $Form = new PerchForm('delete'); if ($Form->posted() && $Form->validate() && isset($item_id)) { $Region->delete_item($item_id); $Region->index(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . $Region->id(); exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/edit/?id=' . $Region->id()); } }
<?php /* --------- Template Form ----------- */ $fTemplate = new PerchForm('template'); $req = array(); $req['regionTemplate'] = "Required"; $fTemplate->set_required($req); if ($fTemplate->posted() && $fTemplate->validate()) { $postvars = array('regionTemplate', 'regionMultiple'); $data = $fTemplate->receive($postvars); if (!isset($data['regionMultiple'])) { $data['regionMultiple'] = 0; } $data['regionNew'] = 0; $Region->update($data); if ($Settings->get('content_singlePageEdit')->val() == '1') { $Region->set_option('edit_mode', 'singlepage'); } else { $Region->set_option('edit_mode', 'listdetail'); } }
<?php $Roles = new PerchUserRoles(); $roles = $Roles->all(); /* --------- New User Form ----------- */ $fCreateUser = new PerchForm('createuser', false); $req = array(); $req['userUsername'] = "******"; $req['userGivenName'] = "Required"; $req['userFamilyName'] = "Required"; $req['userEmail'] = "Required"; $req['userPassword'] = "******"; $req['roleID'] = "Required"; $fCreateUser->set_required($req); $validation = array(); $validation['userUsername'] = array("username", PerchLang::get("Username not available, try another.")); $validation['userEmail'] = array("email", PerchLang::get("Email incomplete or already in use.")); $fCreateUser->set_validation($validation); if ($fCreateUser->posted() && $fCreateUser->validate()) { $data = array(); $postvars = array('userUsername', 'userGivenName', 'userFamilyName', 'userEmail', 'userPassword', 'roleID'); $data = $fCreateUser->receive($postvars); $sendEmail = false; if (isset($_POST['sendEmail']) && $_POST['sendEmail'] == '1') { $sendEmail = true; } $Users->create($data, $sendEmail); $Alert->set('success', PerchLang::get('User successfully created.')); $fCreateUser->clear(); }
<?php $Roles = new PerchUserRoles(); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $Role = $Roles->find($id); } else { $id = false; $Role = false; } if (!$Role || !is_object($Role)) { PerchUtil::redirect(PERCH_LOGINPATH . '/users'); } /* --------- Delete User Form ----------- */ $Form = new PerchForm('delete', false); if ($Form->posted() && $Form->validate()) { $postvars = array('roleID'); $data = $Form->receive($postvars); $Role->migrate_users($data['roleID']); $Role->delete(); if ($Form->submitted_via_ajax) { echo PERCH_LOGINPATH . '/core/users/roles/'; exit; } else { PerchUtil::redirect(PERCH_LOGINPATH . '/core/users/roles/'); } } $details = $Role->to_array(); $all_roles = $Roles->all();
<?php $NavGroups = new PerchContent_NavGroups(); $Pages = new PerchContent_Pages(); $Form = new PerchForm('edit'); $message = false; if (isset($_GET['id']) && is_numeric($_GET['id'])) { $groupID = (int) $_GET['id']; $NavGroup = $NavGroups->find($groupID); } else { $groupID = false; $NavGroup = false; } $Form = new PerchForm('editpage'); $req = array(); $req['groupTitle'] = "Required"; $Form->set_required($req); if ($Form->posted() && $Form->validate()) { $postvars = array('groupTitle'); $data = $Form->receive($postvars); if (is_object($NavGroup)) { $NavGroup->update($data); $Alert->set('success', PerchLang::get('Your navigation group has been successfully updated.')); } else { $data['groupSlug'] = PerchUtil::urlify($data['groupTitle']); $NavGroup = $NavGroups->create($data); if (is_object($NavGroup)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/navigation/edit/?id=' . $NavGroup->id() . '&created=1'); } else { $Alert->set('failure', PerchLang::get('There was a problem creating the navigation group.')); }
<?php $Form = new PerchForm('setup'); $Form->translate_errors = false; $req = array(); $req['licenseKey'] = "Required"; $req['userGivenName'] = "Required"; $req['userFamilyName'] = "Required"; $req['userEmail'] = "Required"; $req['userUsername'] = "******"; $req['userPassword'] = "******"; $req['loginpath'] = "Required"; $req['db_server'] = "Required"; $req['db_database'] = "Required"; $req['db_username'] = "******"; #$req['db_password'] = "******"; $Form->set_required($req); $validation = array(); $validation['userPassword'] = array("password", "Your passwords must match"); $Form->set_validation($validation); if ($Form->posted() && $Form->validate()) { $postvars = array('userGivenName', 'userFamilyName', 'userEmail', 'userUsername', 'userPassword'); $user = $Form->receive($postvars); PerchSession::set('user', $user); $postvars = array('loginpath', 'db_server', 'db_database', 'db_username', 'db_password', 'licenseKey', 'tz'); $conf = $Form->receive($postvars); if (!isset($conf['db_password'])) { $conf['db_password'] = ''; } $conf['loginpath'] = rtrim($conf['loginpath'], '/'); $config_file = file_get_contents('config.sample.php');
<script src="<?php echo PerchUtil::html(PERCH_LOGINPATH); ?> /core/assets/js/perch.min.js?v=<?php echo PerchUtil::html($Perch->version); ?> "></script> <?php $javascript = $Perch->get_javascript(); foreach ($javascript as $js) { echo "\t" . '<script src="' . PerchUtil::html($js) . '"></script>' . "\n"; } ?> <script> Perch.token = '<?php $CSRFForm = new PerchForm('csrf'); echo $CSRFForm->get_token(); ?> '; Perch.path = '<?php echo PerchUtil::html(PERCH_LOGINPATH); ?> '; Perch.version = '<?php echo $Perch->version; ?> '; <?php echo $Perch->get_javascript_blocks(); ?> </script>
public function field_help($string) { $args = func_get_args(); array_shift($args); $string = $this->Lang->get($string, $args); return parent::hint($string); }
<?php $Form = new PerchForm('reorder', false); if ($Form->posted() && $Form->validate()) { if ($Form->submitted_via_ajax) { $Settings->set('dashboard_order', $_POST['order'], $CurrentUser->id()); echo $Form->get_token(); exit; } }
<?php $Roles = new PerchUserRoles(); $Privs = new PerchUserPrivileges(); if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $Role = $Roles->find($id); } else { $id = false; $Role = false; } $Form = new PerchForm('role', false); $req = array(); $req['roleTitle'] = "Required"; $Form->set_required($req); if ($Form->posted() && $Form->validate()) { PerchUtil::debug($_POST); $data = array(); $postvars = array('roleTitle'); $data = $Form->receive($postvars); $data['roleSlug'] = PerchUtil::urlify($data['roleTitle']); if (is_object($Role)) { $Role->update($data); } else { $Role = $Roles->create($data); } $privs = $Form->find_items('privs-'); $new_privs = array(); if (PerchUtil::count($privs)) { foreach ($privs as $category) { if (PerchUtil::count($category)) {
$Items = new PerchContent_Items(); $Region = false; // Find the region if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $Region = $Regions->find($id); } // Check we have a region if (!$Region || !is_object($Region)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/'); } // Check permissions if (!$Region->role_may_edit($CurrentUser)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/edit/denied/'); } $Form = new PerchForm('reorder'); if ($Form->posted() && $Form->validate()) { $items = $Form->find_items('item_'); if (PerchUtil::count($items)) { foreach ($items as $itemID => $itemOrder) { $Item = $Items->find_item($Region->id(), $itemID, $Region->regionLatestRev()); if (is_object($Item)) { $data = array(); $data['itemOrder'] = (int) $itemOrder; $Item->update($data); } } $Region->set_option('sortField', ''); if (!$Region->has_draft()) { $Region->publish(); $Region->index();
<?php if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $count = PerchUtil::count($PerchPage->get_list()) + 1; } if ($id !== $count) { PerchUtil::redirect(PERCH_LOGINPATH . '/apps/perchpages'); } // Check permission to add if ($CurrentUser->userRole() == 'Editor' && !$Settings->get('editorMayDeleteRegions')->settingValue()) { PerchUtil::redirect(PERCH_LOGINPATH . '/apps/perchpages'); } /* --------- Add Form ----------- */ $Form = new PerchForm('add'); $req = array(); $req['fileTemplate'] = 'Required'; $req['fileAlias'] = 'Required'; $req['fileDir'] = 'Required'; $req['fileName'] = 'Required'; $req['fileNameExt'] = 'Required'; $Form->set_required($req); $Form->posted = $Form->find_items('file'); $fileNameExts = array(array('label' => '.php', 'value' => 'php'), array('label' => '.html', 'value' => 'html'), array('label' => '.htm', 'value' => 'htm')); if ($Form->posted() && $Form->validate()) { $Form->posted['Location'] = $Form->posted['Dir'] . '/' . $Form->posted['Name'] . '.' . $Form->posted['NameExt']; unset($Form->posted['Dir'], $Form->posted['Name'], $Form->posted['NameExt']); if (!$PerchPage->copy_template($Form->posted['Template'], $Form->posted['Location'])) { PerchUtil::redirect(PERCH_LOGINPATH . '/apps/perchpages/?failure=add'); return false; }
} // Find the page if (isset($_GET['id']) && is_numeric($_GET['id'])) { $id = (int) $_GET['id']; $Page = $Pages->find($id); } // Check we have a page if (!$Page || !is_object($Page)) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/'); } // Check permissions if (!$CurrentUser->has_priv('content.pages.edit')) { PerchUtil::redirect(PERCH_LOGINPATH . '/core/apps/content/'); } $ParentPage = $Pages->find($Page->pageParentID()); $Form = new PerchForm('editpage'); $req = array(); $req['pagePath'] = "Required"; $Form->set_required($req); if ($Form->posted() && $Form->validate()) { $postvars = array('pagePath', 'pageSubpagePath', 'pageHidden', 'pageAccessTags', 'pageAttributeTemplate'); if (PERCH_RUNWAY) { $postvars[] = 'templateID'; } $data = $Form->receive($postvars); if (!isset($data['pageHidden'])) { $data['pageHidden'] = '0'; } if (!PERCH_RUNWAY) { if (!isset($data['pageSubpagePath'])) { $data['pageSubpagePath'] = false;
$details = $Region->get_items_for_editing($item_id); } else { $details = $Region->get_items_for_editing(); if (PerchUtil::count($details) == 0) { $Region->add_new_item(); } $details = $Region->get_items_for_editing(); } $item_count = PerchUtil::count($details); $template_help_html = ''; $mapcount = 0; $has_map = false; $Perch = Perch::fetch(); /* --------- Undo Form ----------- */ if ($Region->regionTemplate() != '') { $fUndo = new PerchForm('undo'); if ($fUndo->posted()) { if ($Region->revert_most_recent()) { $Region->index(); if (isset($item_id) && $item_id) { $details = $Region->get_items_for_editing($item_id); } else { $details = $Region->get_items_for_editing(); } $Perch->event('page.publish', $Page); $Alert->set('success', PerchLang::get('Your most recent change has been reverted.')); } else { $Alert->set('error', PerchLang::get('There was nothing to undo.')); } } }