当前位置: 首页>>代码示例>>PHP>>正文


PHP Director类代码示例

本文整理汇总了PHP中Director的典型用法代码示例。如果您正苦于以下问题:PHP Director类的具体用法?PHP Director怎么用?PHP Director使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Director类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: listjobtotalsAction

 function listjobtotalsAction()
 {
     $this->view->title = $this->view->translate->_("List of Job Totals");
     // do Bacula ACLs
     $command = 'list';
     if (!$this->bacula_acl->doOneBaculaAcl($command, 'command')) {
         $msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $command);
         $this->_forward('bacula-access-denied', 'error', null, array('msg' => $msg));
         // action, controller
         return;
     }
     $director = new Director();
     if (!$director->isFoundBconsole()) {
         $this->view->result_error = 'NOFOUND_BCONSOLE';
         $this->render();
         return;
     }
     $astatusdir = $director->execDirector(" <<EOF\nlist jobtotals\n@quit\nEOF");
     $this->view->command_output = $astatusdir['command_output'];
     // check return status of the executed command
     if ($astatusdir['return_var'] != 0) {
         $this->view->result_error = $astatusdir['result_error'];
     }
     $this->view->meta_refresh = 300;
     // meta http-equiv="refresh"
 }
开发者ID:staser,项目名称:webacula,代码行数:26,代码来源:DirectorController.php

示例2: statusClientIdAction

 function statusClientIdAction()
 {
     // http://localhost/webacula/client/status-client-id/id/1/name/local.fd
     $client_name = $this->_getParam('name');
     $this->view->title = $this->view->translate->_("Client") . " " . $client_name;
     // do Bacula ACLs
     $command = 'status';
     if (!$this->bacula_acl->doOneBaculaAcl($command, 'command')) {
         $msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $command);
         $this->_forward('bacula-access-denied', 'error', null, array('msg' => $msg));
         // action, controller
         return;
     }
     $director = new Director();
     if (!$director->isFoundBconsole()) {
         $this->view->result_error = 'NOFOUND_BCONSOLE';
         $this->render();
         return;
     }
     $astatusdir = $director->execDirector(" <<EOF\nstatus client=\"{$client_name}\"\n.\n@quit\nEOF");
     $this->view->command_output = $astatusdir['command_output'];
     // check return status of the executed command
     if ($astatusdir['return_var'] != 0) {
         $this->view->result_error = $astatusdir['result_error'];
     }
     $this->view->meta_refresh = 300;
     // meta http-equiv="refresh"
 }
开发者ID:staser,项目名称:webacula,代码行数:28,代码来源:ClientController.php

示例3: cmdAction

 function cmdAction()
 {
     $bcommand = addslashes(trim($this->_request->getPost('bcommand')));
     $this->view->bcommand = $bcommand;
     if ($this->_helper->hasHelper('layout')) {
         $this->_helper->layout->disableLayout();
         // disable layouts
     }
     list($cmd) = explode(' ', $bcommand);
     // do Bacula ACLs
     if (!$this->bacula_acl->doOneBaculaAcl($cmd, 'command')) {
         $this->view->msg = sprintf($this->view->translate->_('You try to run Bacula Console with command "%s".'), $cmd) . '<br><b>Bacula ACLs : ' . $this->view->translate->_('Access denied.') . '</b><br>';
         $this->render();
         return;
     }
     $director = new Director();
     if (!$director->isFoundBconsole()) {
         $this->view->msg = '<b>' . $this->view->translate->_('ERROR: bconsole not found.') . '</b><br>';
         $this->render();
         return;
     }
     $astatusdir = $director->execDirector("<<EOF\n{$bcommand}\n@quit\nEOF");
     $this->view->command_output = $astatusdir['command_output'];
     // check return status of the executed command
     $this->view->return_var = $astatusdir['return_var'];
 }
开发者ID:staser,项目名称:webacula,代码行数:26,代码来源:BconsoleController.php

示例4: testBuilder

 public function testBuilder()
 {
     $expect = "<header>Header</header>\n" + "<article>Content</article>\n" + "<footer>Footer</footer>\n";
     $product = new Product();
     $director = new Director(new ConcreteBuilder($product));
     $director->construct();
     $result = $product->show();
     $this->assertEquals($result, $expect);
 }
开发者ID:AlexanderGrom,项目名称:php-patterns,代码行数:9,代码来源:builder_test.php

示例5: main

 public static function main()
 {
     $builder = new ConcreteBuilder();
     $director = new Director($builder);
     $product = $director->getProduct();
     $product->show();
     $builder = null;
     $director = null;
     $product = null;
 }
开发者ID:luisOO,项目名称:design-patterns,代码行数:10,代码来源:builder.php

示例6: photo

 public static function photo($reference, $maxWidth = 0)
 {
     if ((int) $maxWidth === 0) {
         $maxWidth = \App\Lib\Api\GooglePlace\Config::radius();
     }
     $photoBuilder = new BuilderPhoto();
     $photoBuilder->setupMaxWidth($maxWidth);
     $photoBuilder->setupPhotoReference($reference);
     $photoBuilder->setupDataType();
     $director = new Director($photoBuilder);
     $director->construct();
     $request = $director->getResult();
     $response = $request->send();
     return $response;
 }
开发者ID:majchrosoft,项目名称:bars-in-cracow,代码行数:15,代码来源:Facade.php

示例7: handleRequest

 /**
  * @uses ModelAsController::getNestedController()
  * @param SS_HTTPRequest $request
  * @param DataModel $model
  * @return SS_HTTPResponse
  */
 public function handleRequest(SS_HTTPRequest $request, DataModel $model)
 {
     $this->setRequest($request);
     $this->setDataModel($model);
     $this->pushCurrent();
     // Create a response just in case init() decides to redirect
     $this->response = new SS_HTTPResponse();
     $this->init();
     // If we had a redirection or something, halt processing.
     if ($this->response->isFinished()) {
         $this->popCurrent();
         return $this->response;
     }
     // If the database has not yet been created, redirect to the build page.
     if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
         $this->response->redirect(Director::absoluteBaseURL() . 'dev/build?returnURL=' . (isset($_GET['url']) ? urlencode($_GET['url']) : null));
         $this->popCurrent();
         return $this->response;
     }
     try {
         $result = $this->getNestedController();
         if ($result instanceof RequestHandler) {
             $result = $result->handleRequest($this->getRequest(), $model);
         } else {
             if (!$result instanceof SS_HTTPResponse) {
                 user_error("ModelAsController::getNestedController() returned bad object type '" . get_class($result) . "'", E_USER_WARNING);
             }
         }
     } catch (SS_HTTPResponse_Exception $responseException) {
         $result = $responseException->getResponse();
     }
     $this->popCurrent();
     return $result;
 }
开发者ID:kamrandotpk,项目名称:silverstripe-cms,代码行数:40,代码来源:ModelAsController.php

示例8: testFindLink

 public function testFindLink()
 {
     $this->checkoutpage = $this->objFromFixture('CheckoutPage', 'checkout');
     $this->checkoutpage->publish('Stage', 'Live');
     $link = CheckoutPage::find_link();
     $this->assertEquals(Director::baseURL() . 'checkout/', $link, 'find_link() returns the correct link to checkout.');
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:7,代码来源:CheckoutPageTest.php

示例9: preRequest

 /**
  * Filter executed before a request processes
  *
  * @param SS_HTTPRequest $request Request container object
  * @param Session $session Request session
  * @param DataModel $model Current DataModel
  * @return boolean Whether to continue processing other filters. Null or true will continue processing (optional)
  */
 public function preRequest(SS_HTTPRequest $request, Session $session, DataModel $model)
 {
     if (!\Director::is_cli() && ($response = $this->redirector->getResponse($request))) {
         $response->output();
         exit;
     }
 }
开发者ID:helpfulrobot,项目名称:heyday-silverstripe-redirects,代码行数:15,代码来源:RequestFilter.php

示例10: dosave

 /**
  * Form action handler for ContactInquiryForm.
  *
  * @param array $data The form request data submitted
  * @param Form $form The {@link Form} this was submitted on
  */
 function dosave(array $data, Form $form, SS_HTTPRequest $request)
 {
     $SQLData = Convert::raw2sql($data);
     $attrs = $form->getAttributes();
     if ($SQLData['Comment'] != '' || $SQLData['Url'] != '') {
         // most probably spam - terminate silently
         Director::redirect(Director::baseURL() . $this->URLSegment . "/success");
         return;
     }
     $item = new ContactInquiry();
     $form->saveInto($item);
     // $form->sessionMessage(_t("ContactPage.FORMMESSAGEGOOD", "Your inquiry has been submitted. Thanks!"), 'good');
     $item->write();
     $mailFrom = $this->currController->MailFrom ? $this->currController->MailFrom : $SQLData['Email'];
     $mailTo = $this->currController->MailTo ? $this->currController->MailTo : Email::getAdminEmail();
     $mailSubject = $this->currController->MailSubject ? $this->currController->MailSubject . ' - ' . $SQLData['Ref'] : _t('ContactPage.SUBJECT', '[web] New contact inquiry - ') . ' ' . $data['Ref'];
     $email = new Email($mailFrom, $mailTo, $mailSubject);
     $email->replyTo($SQLData['Email']);
     $email->setTemplate("ContactInquiry");
     $email->populateTemplate($SQLData);
     $email->send();
     // $this->controller->redirectBack();
     if ($email->send()) {
         $this->controller->redirect($this->controller->Link() . "success");
     } else {
         $this->controller->redirect($this->controller->Link() . "error");
     }
     return false;
 }
开发者ID:helpfulrobot,项目名称:jelicanin-silverstripe-contact-page,代码行数:35,代码来源:ContactInquiryForm.php

示例11: testGetTagWithoutTitleContainingDots

	function testGetTagWithoutTitleContainingDots() {
		$image = $this->objFromFixture('Image', 'imageWithoutTitleContainingDots');
		$expected = '<img src="' . Director::baseUrl() . 'assets/ImageTest/test.image.with.dots.png" alt="test.image.with.dots" />';
		$actual = $image->getTag();
		
		$this->assertEquals($expected, $actual);
	}
开发者ID:redema,项目名称:sapphire,代码行数:7,代码来源:ImageTest.php

示例12: FieldHolder

 /**
  * @param array $properties
  *
  * @return string - HTML
  */
 public function FieldHolder($properties = array())
 {
     $moduleDir = substr(Director::makeRelative(dirname(dirname(dirname(__FILE__)))), 1);
     Requirements::css($moduleDir . '/css/WidgetAreaEditor.css');
     Requirements::javascript($moduleDir . '/javascript/WidgetAreaEditor.js');
     return $this->renderWith("WidgetAreaEditor");
 }
开发者ID:JayDevlin,项目名称:silverstripe-widgets,代码行数:12,代码来源:WidgetAreaEditor.php

示例13: run

 /**
  * @param	SS_HTTPRequest $request
  */
 public function run($request)
 {
     // Only allow execution from the command line (for simplicity).
     if (!Director::is_cli()) {
         echo "<p>Sorry, but this can only be run from the command line.</p>";
         return;
     }
     try {
         // Get and validate desired maintenance mode setting.
         $get = $request->getVars();
         if (empty($get["args"])) {
             throw new Exception("Please provide an argument (e.g. 'on' or 'off').", 1);
         }
         $arg = strtolower(current($get["args"]));
         if ($arg != "on" && $arg != "off") {
             throw new Exception("Invalid argument: '{$arg}' (expected 'on' or 'off')", 2);
         }
         // Get and write site configuration now.
         $config = SiteConfig::current_site_config();
         $previous = !empty($config->MaintenanceMode) ? "on" : "off";
         $config->MaintenanceMode = $arg == "on";
         $config->write();
         // Output status and exit.
         if ($arg != $previous) {
             $this->output("Maintenance mode is now '{$arg}'.");
         } else {
             $this->output("NOTE: Maintenance mode was already '{$arg}' (nothing has changed).");
         }
     } catch (Exception $e) {
         $this->output("ERROR: " . $e->getMessage());
         if ($e->getCode() <= 2) {
             $this->output("Usage:  sake dev/tasks/MaintenanceMode [on|off]");
         }
     }
 }
开发者ID:helpfulrobot,项目名称:thisisbd-silverstripe-maintenance-mode,代码行数:38,代码来源:MaintenanceMode.php

示例14: onBeforeInit

 public function onBeforeInit()
 {
     $host = GlobalNavSiteTreeExtension::get_toolbar_hostname();
     if ((isset($_REQUEST['regenerate_nav']) || isset($_REQUEST['flush'])) && $host == Director::protocolAndHost() && (Permission::check('ADMIN') || Director::isDev())) {
         GlobalNavSiteTreeExtension::create_static_navs();
     }
 }
开发者ID:newleeland,项目名称:silverstripe-globaltoolbar,代码行数:7,代码来源:GlobalNavControllerExtension.php

示例15: submitPoll

 function submitPoll($data, $form)
 {
     $choiceIDs = is_array($data['PollChoices']) ? $data['PollChoices'] : array($data['PollChoices']);
     $choicesIDs = implode(',', $choiceIDs);
     $choices = DataObject::get('PollChoice', sprintf('"ID" IN (%s)', $choicesIDs));
     if ($choices) {
         foreach ($choices as $choice) {
             $choice->addVote();
         }
         $form->poll->markAsVoted();
     }
     // Redirect back to anchor (partly copied from Director::redirectBack)
     if (self::$redirect_to_anchor) {
         if ($this->request->requestVar('_REDIRECT_BACK_URL')) {
             $url = $this->request->requestVar('_REDIRECT_BACK_URL');
         } else {
             if ($this->request->getHeader('Referer')) {
                 $url = $this->request->getHeader('Referer');
             } else {
                 $url = Director::baseURL();
             }
         }
         $url .= '#' . self::$redirect_to_anchor . '-' . $this->poll->ID;
         $this->controller->redirect($url);
     } else {
         $this->controller->redirectBack();
     }
 }
开发者ID:helpfulrobot,项目名称:mateusz-silverstripe-polls,代码行数:28,代码来源:PollForm.php


注:本文中的Director类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。