/** * Controller method to allow the page metadata to be edited. * * @return int */ public function updatelisting() { $view = $this->getView(); $manager = \Core\user()->checkAccess('p:/gallery/manage_all'); if (!$manager) { return View::ERROR_ACCESSDENIED; } $page = new PageModel('/gallery'); $form = Form::BuildFromModel($page); $form->set('callsmethod', 'GalleryController::UpdateListingSave'); $form->addElement('submit', array('value' => 'Update Listing')); $view->title = 'Edit Gallery Listing Page'; $view->assign('form', $form); }
public function create() { $view = $this->getView(); $m = new NavigationModel(); $form = Form::BuildFromModel($m); $form->set('callsmethod', 'NavigationController::_SaveHandler'); // I only want non-fuzzy pages to display. //$views = PageModel::GetPagesAsOptions("fuzzy = 0"); $views = PageModel::GetPagesAsOptions(); $view->mastertemplate = 'admin'; $view->title = 'New Navigation Menu'; $view->templatename = '/pages/navigation/create.tpl'; $view->assignVariable('model', $m); $view->assignVariable('form', $form); $view->assignVariable('pages', $views); $view->addControl('Navigation Listings', '/Navigation', 'directory'); }
public function repos_edit() { $request = $this->getPageRequest(); $view = $this->getView(); $site = UpdateSiteModel::Construct($request->getParameter(0)); if(!$site->exists()){ return View::ERROR_NOTFOUND; } $form = Form::BuildFromModel($site); $form->set('callsmethod', 'UpdaterController::_SaveRepo'); $form->addElement('submit', array('value' => 'Update')); $view->title = 'Update Repo'; // Needed because dynamic pages do not record navigation. $view->addBreadcrumb('Repositories', 'updater/repos'); $view->assign('form', $form); }
public function update(){ $view = $this->getView(); $req = $this->getPageRequest(); $id = $req->getParameter(0); $model = new UserGroupModel($id); $form = Form::BuildFromModel($model); $contextnames = []; $contexts = []; $usecontexts = false; $contextlocked = (sizeof($model->getLink('UserUserGroup')) > 0); $isadmin = \Core\user()->checkAccess('g:admin'); if(!$model->exists()){ return View::ERROR_NOERROR; } if(Core::IsComponentAvailable('multisite') && MultiSiteHelper::IsEnabled()){ $siteid = MultiSiteHelper::GetCurrentSiteID(); if($isadmin){ $form->switchElementType('model[site]', 'select'); $form->getElement('model[site]')->setFromArray( [ 'title' => 'Site Scope', 'options' => MultiSiteModel::GetAllAsOptions(), //'options' => ['-1' => 'Global Scope', '0' => 'Local Scope'], 'description' => 'A globally-scoped group is visible across every site.' ] ); } } if(\Core\user()->checkAccess('p:/user/permissions/manage')){ // The user has access to manage user permissions.... the enclosed is that full logic for edits. foreach(Core::GetPermissions() as $key => $data){ $ckey = $data['context']; $ctitle = ($ckey == '') ? '** Global Context Permissions **' : $ckey . ' Context Permissions'; $contextnames[$ckey] = $ctitle; $contexts[$key] = $ckey; } if(sizeof($contextnames) > 1){ if(!$contextlocked){ // There are contexts defined and this group has not yet been added to a user's profile, // editing of the context is still permitted. $form->getElement('model[context]')->set('options', $contextnames); $usecontexts = true; } else{ // This group has been added to a user's profile, display a message that it's locked! \Core\set_message('This group has been added to a user account and therefore has been locked to the ' . $contextnames[$model->get('context')]); $form->switchElementType('model[context]', 'hidden'); $usecontexts = true; } } else{ $form->removeElement('model[context]'); } $this->_setPermissionsToForm($form, $model); } else{ // No permission edit access, just remove the context options too! $form->removeElement('model[context]'); } // If this group is locked and not a global group, it cannot be defined as a default group! if($contextlocked && $model->get('context') != ''){ $form->removeElement('model[default]'); } $form->set('callsmethod', 'UserGroupAdminController::_UpdateFormHandler'); $form->addElement('submit', array('value' => 'Update')); $view->templatename = 'pages/usergroupadmin/create_update.tpl'; $view->title = 'Update Group ' . $model->get('name'); $view->assign('model', $model); $view->assign('form', $form); $view->assign('context_json', json_encode($contexts)); $view->assign('use_contexts', $usecontexts); }
public function editor() { $view = $this->getView(); $request = $this->getPageRequest(); if (!$this->setAccess('g:admin')) { return View::ERROR_ACCESSDENIED; } if ($request->getParameter('template')) { // This is the basename of the file, (unresolved) // example: "skins/basic.tpl" $file = $request->getParameter('template'); // And the fully resolved one! // example: "/home/blah/public_html/themes/awesome-one/skins/basic.tpl" $filename = \Core\Templates\Template::ResolveFile($file); // This gets resolved automatically. $mode = null; $activefile = 'template'; } elseif ($request->getParameter('file') && strpos($request->getParameter('file'), 'assets/') === 0) { $file = $request->getParameter('file'); // Trim off the base of the filename, ("assets/") $filename = substr($file, 7); // And try to look up and find this damn file... $srcdirs = array(); $srcdirs[] = ROOT_PDIR . 'themes/custom/assets/'; $srcdirs[] = ROOT_PDIR . 'themes/' . ConfigHandler::Get('/theme/selected') . '/assets/'; foreach (Core::GetComponents() as $c) { if ($c->getAssetDir()) { $srcdirs[] = $c->getAssetDir(); } } foreach ($srcdirs as $dir) { if (file_exists($dir . $filename)) { $filename = $dir . $filename; break; } } // This gets resolved automatically. $mode = null; $activefile = 'file'; } else { //no special gets... // This version of the editor doesn't support viewing without any file specified. \Core\set_message('No file requested', 'error'); \core\redirect('/theme'); } $fh = \Core\Filestore\Factory::File($filename); $customdest = \Core\directory('themes/custom'); if (!$customdest->isWritable()) { \Core\set_message('Directory themes/custom is not writable! Inline file editing disabled.', 'error'); \Core\go_back(); } // Lookup the mode. if (!$mode) { switch ($fh->getMimetype()) { case 'text/css': $mode = 'css'; break; case 'text/javascript': $mode = 'javascript'; break; case 'text/html': $mode = 'htmlmixed'; break; default: $mode = 'smarty'; break; } } // @todo Finish this. if (strpos($fh->getMimetype(), 'text/') !== 0) { \Core\set_message('Sorry, but only text files can be edited right now... Expect this to function soon though ;)', 'info'); \Core\go_back(); } // Load the last 10 revisions from the database. $revisions = ThemeTemplateChangeModel::Find(array('filename' => $file), 10, 'updated DESC'); $rev = null; if ($request->getParameter('revision')) { // Look up that revision. $rev = ThemeTemplateChangeModel::Construct($request->getParameter('revision')); if ($rev->get('filename') == $file) { $content = $rev->get('content'); $revision = $rev->get('id'); } else { \Core\set_message('Invalid revision requested!', 'error'); $rev = null; } } if (!$rev) { // No revision requested, just pull the contents from the live file $content = $fh->getContents(); if (sizeof($revisions)) { // Grab the latest one! $rev = $revisions[0]; } } if ($rev && $rev == $revisions[0]) { $islatest = true; } elseif (!$rev) { $islatest = true; } else { $islatest = false; } $basename = $fh->getBasename(); $m = new ThemeTemplateChangeModel(); $m->set('content', $content); $m->set('filename', $file); $form = Form::BuildFromModel($m); $form->set('callsmethod', 'ThemeController::_SaveEditorHandler'); // I need to add the file as a system element so core doesn't try to reuse the same forms on concurrent edits. //$form->addElement('system', array('name' => 'revision', 'value' => $revision)); $form->addElement('system', array('name' => 'file', 'value' => $file)); $form->addElement('system', array('name' => 'filetype', 'value' => $activefile)); if (!$islatest) { $form->addElement('submit', array('value' => 'Update/Revert')); } else { $form->addElement('submit', array('value' => 'Update')); } // This form needs to load the content live on every pageload! // This is because the user can jump between the different versions on-the-fly, // so if the form system has its way, it would keep the first in cache and only display that. // No cache for you! $form->clearFromSession(); $view->assign('activefile', $activefile); $view->assign('form', $form); $view->assign('content', $content); $view->assign('filename', $basename); $view->assign('revisions', $revisions); $view->assign('revision', $rev); $view->assign('file', $file); $view->assign('fh', $fh); $view->assign('islatest', $islatest); $view->assign('mode', $mode); //$view->addBreadcrumb('Theme Manager', '/theme'); $view->title = 'Editor'; }