public function index(SS_HTTPRequest $request)
 {
     if (!Director::isDev() && !Permission::check('CMS_ACCESS_CMSMain')) {
         return Security::permissionFailure($this);
     }
     if ($request->latestParam('ID')) {
         $templates = $this->templateArray();
         if (isset($templates[$request->latestParam('ID')])) {
             $next = false;
             $previous = false;
             $useNext = false;
             foreach ($templates as $k => $v) {
                 if ($useNext) {
                     $next = new ArrayData(array('Name' => $v['Name'], 'Link' => 'patterns/index/' . $k));
                     break;
                 }
                 if ($k == $request->latestParam('ID')) {
                     // mat
                     $useNext = true;
                 } else {
                     $previous = new ArrayData(array('Name' => $v['Name'], 'Link' => 'patterns/index/' . $k));
                 }
             }
             return $this->customise(new ArrayData(array('IsPatternLab' => true, 'PreviousPattern' => $previous, 'NextPattern' => $next, 'PatternName' => $templates[$request->latestParam('ID')]['Name'], 'Patterns' => $this->renderWith(array($templates[$request->latestParam('ID')]['Name'])))))->renderWith('Page');
         }
     }
     return $this->renderWith(array(__CLASS__, 'Page'));
 }
Ejemplo n.º 2
0
 /**
  * Controller Action
  *
  * @param SS_HTTPRequest $request
  * @return APIEnvironment
  */
 public function environment(SS_HTTPRequest $request)
 {
     $project = $this->getProject();
     if (!$project) {
         return new SS_HTTPResponse('Project "' . Convert::raw2xml($request->latestParam('Project')) . '" not found.', 404);
     }
     $environment = $this->getEnvironment();
     if (!$environment) {
         return new SS_HTTPResponse('Environment "' . Convert::raw2xml($request->latestParam('Environment')) . '" not found.', 404);
     }
     return new APIEnvironment($this, $environment);
 }
 public function approvealert(SS_HTTPRequest $request)
 {
     $this->owner->setCurrentActionType(self::ACTION_ALERT);
     $project = $this->getCurrentProject();
     if (!$project) {
         return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404);
     }
     return $this->owner->customise(['Title' => 'Alert approval', 'CurrentProject' => $project])->render();
 }
Ejemplo n.º 4
0
 /**
  * @param  SS_HTTPRequest $request
  * @param  DNDataArchive $dataArchive Only set when method is called manually, otherwise the state is inferred from
  *	the request data.
  * @return Form
  */
 public function getDeleteForm($request, $dataArchive = null)
 {
     $dataArchive = $dataArchive ? $dataArchive : DNDataArchive::get()->byId($request->requestVar('DataArchiveID'));
     // Performs canView permission check by limiting visible projects
     $project = $this->getCurrentProject();
     if (!$project) {
         return new SS_HTTPResponse("Project '" . Convert::raw2xml($request->latestParam('Project')) . "' not found.", 404);
     }
     $form = new Form($this, 'DeleteForm', new FieldList(new HiddenField('DataArchiveID', false, $dataArchive->ID), new LiteralField('Warning', '<p class="text-warning">Are you sure you want to permanently delete this snapshot from this archive area?</p>')), new FieldList(FormAction::create('doDelete', 'Delete')->addExtraClass('btn')));
     $form->setFormAction($project->Link() . '/DeleteForm');
     return $form;
 }