Import some code, some of which may be relevant to the project.
This commit is contained in:
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
abstract class AphrontApplicationConfiguration {
|
||||
|
||||
private $request;
|
||||
private $host;
|
||||
private $path;
|
||||
|
||||
abstract public function getApplicationName();
|
||||
abstract public function getURIMap();
|
||||
abstract public function buildRequest();
|
||||
|
||||
final public function setRequest(AphrontRequest $request) {
|
||||
$this->request = $request;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
final public function buildController() {
|
||||
$map = $this->getURIMap();
|
||||
$mapper = new AphrontURIMapper($map);
|
||||
$request = $this->getRequest();
|
||||
$path = $request->getPath();
|
||||
list($controller_class, $uri_data) = $mapper->mapPath($path);
|
||||
|
||||
PhutilSymbolLoader::loadClass($controller_class);
|
||||
$controller = newv($controller_class, array($request));
|
||||
|
||||
return array($controller, $uri_data);
|
||||
}
|
||||
|
||||
final public function setHost($host) {
|
||||
$this->host = $host;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getHost() {
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
final public function setPath($path) {
|
||||
$this->path = $path;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getPath() {
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
}
|
||||
15
src/aphront/applicationconfiguration/__init__.php
Normal file
15
src/aphront/applicationconfiguration/__init__.php
Normal file
@@ -0,0 +1,15 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/mapper');
|
||||
|
||||
phutil_require_module('phutil', 'symbols');
|
||||
phutil_require_module('phutil', 'utils');
|
||||
|
||||
|
||||
phutil_require_source('AphrontApplicationConfiguration.php');
|
||||
48
src/aphront/controller/AphrontController.php
Normal file
48
src/aphront/controller/AphrontController.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
abstract class AphrontController {
|
||||
|
||||
private $request;
|
||||
|
||||
public function willProcessRequest(array $uri_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
abstract public function processRequest();
|
||||
|
||||
final public function __construct(AphrontRequest $request) {
|
||||
$this->request = $request;
|
||||
}
|
||||
|
||||
final public function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function buildStandardPageResponse($view) {
|
||||
$page = new AphrontStandardPageView();
|
||||
$page->appendChild($view);
|
||||
$response = new AphrontWebpageResponse();
|
||||
$response->setContent($page->render());
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
13
src/aphront/controller/__init__.php
Normal file
13
src/aphront/controller/__init__.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/response/webpage');
|
||||
phutil_require_module('aphront', 'view/page/standard');
|
||||
|
||||
|
||||
phutil_require_source('AphrontController.php');
|
||||
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
class AphrontDefaultApplicationConfiguration
|
||||
extends AphrontApplicationConfiguration {
|
||||
|
||||
public function getApplicationName() {
|
||||
return 'aphront-default';
|
||||
}
|
||||
|
||||
public function getURIMap() {
|
||||
return array(
|
||||
'/repository/' => array(
|
||||
'$' => 'RepositoryListController',
|
||||
'new/$' => 'RepositoryEditController',
|
||||
'edit/(?<id>\d+)/$' => 'RepositoryEditController',
|
||||
'delete/(?<id>\d+)/$' => 'RepositoryDeleteController',
|
||||
),
|
||||
'/' => array(
|
||||
'$' => 'AphrontDirectoryMainController',
|
||||
),
|
||||
'/directory/' => array(
|
||||
'item/$' => 'AphrontDirectoryItemListController',
|
||||
'item/edit/(?:(?<id>\d+)/)?$' => 'AphrontDirectoryItemEditController',
|
||||
'item/delete/(?<id>\d+)/' => 'AphrontDirectoryItemDeleteController',
|
||||
'category/$'
|
||||
=> 'AphrontDirectoryCategoryListController',
|
||||
'category/edit/(?:(?<id>\d+)/)?$'
|
||||
=> 'AphrontDirectoryCategoryEditController',
|
||||
'category/delete/(?<id>\d+)/'
|
||||
=> 'AphrontDirectoryCategoryDeleteController',
|
||||
),
|
||||
'.*' => 'AphrontDefaultApplicationController',
|
||||
);
|
||||
}
|
||||
|
||||
public function buildRequest() {
|
||||
$request = new AphrontRequest($this->getHost(), $this->getPath());
|
||||
$request->setRequestData($_GET + $_POST);
|
||||
return $request;
|
||||
}
|
||||
|
||||
public function handleException(Exception $ex) {
|
||||
|
||||
$class = phutil_escape_html(get_class($ex));
|
||||
$message = phutil_escape_html($ex->getMessage());
|
||||
|
||||
$content =
|
||||
'<div class="aphront-unhandled-exception">'.
|
||||
'<h1>Unhandled Exception "'.$class.'": '.$message.'</h1>'.
|
||||
'<code>'.phutil_escape_html((string)$ex).'</code>'.
|
||||
'</div>';
|
||||
|
||||
$view = new AphrontStandardPageView();
|
||||
$view->appendChild($content);
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
$response->setContent($view->render());
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
public function willSendResponse(AphrontResponse $response) {
|
||||
$request = $this->getRequest();
|
||||
if ($response instanceof AphrontDialogResponse) {
|
||||
if (!$request->isAjax()) {
|
||||
$view = new AphrontStandardPageView();
|
||||
$view->appendChild(
|
||||
'<div style="padding: 2em 0;">'.
|
||||
$response->buildResponseString().
|
||||
'</div>');
|
||||
$response = new AphrontWebpageResponse();
|
||||
$response->setContent($view->render());
|
||||
return $response;
|
||||
}
|
||||
}
|
||||
|
||||
return $response;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
17
src/aphront/default/configuration/__init__.php
Normal file
17
src/aphront/default/configuration/__init__.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/applicationconfiguration');
|
||||
phutil_require_module('aphront', 'aphront/request');
|
||||
phutil_require_module('aphront', 'aphront/response/webpage');
|
||||
phutil_require_module('aphront', 'view/page/standard');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
|
||||
|
||||
phutil_require_source('AphrontDefaultApplicationConfiguration.php');
|
||||
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
class AphrontDefaultApplicationController extends AphrontController {
|
||||
|
||||
public function processRequest() {
|
||||
$request = $this->getRequest();
|
||||
|
||||
$path = phutil_escape_html($request->getPath());
|
||||
$host = phutil_escape_html($request->getHost());
|
||||
$controller_name = phutil_escape_html(get_class($this));
|
||||
|
||||
$page = new AphrontStandardPageView();
|
||||
|
||||
$response = new AphrontWebpageResponse();
|
||||
$response->setContent($page->render());
|
||||
return $response;
|
||||
}
|
||||
|
||||
}
|
||||
16
src/aphront/default/controller/__init__.php
Normal file
16
src/aphront/default/controller/__init__.php
Normal file
@@ -0,0 +1,16 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/controller');
|
||||
phutil_require_module('aphront', 'aphront/response/webpage');
|
||||
phutil_require_module('aphront', 'view/page/standard');
|
||||
|
||||
phutil_require_module('phutil', 'markup');
|
||||
|
||||
|
||||
phutil_require_source('AphrontDefaultApplicationController.php');
|
||||
68
src/aphront/mapper/AphrontURIMapper.php
Normal file
68
src/aphront/mapper/AphrontURIMapper.php
Normal file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
final class AphrontURIMapper {
|
||||
|
||||
private $map;
|
||||
|
||||
final public function __construct(array $map) {
|
||||
$this->map = $map;
|
||||
}
|
||||
|
||||
final public function mapPath($path) {
|
||||
$map = $this->map;
|
||||
foreach ($map as $rule => $value) {
|
||||
list($controller, $data) = $this->tryRule($rule, $value, $path);
|
||||
if ($controller) {
|
||||
foreach ($data as $k => $v) {
|
||||
if (is_numeric($k)) {
|
||||
unset($data[$k]);
|
||||
}
|
||||
}
|
||||
return array($controller, $data);
|
||||
}
|
||||
}
|
||||
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
final private function tryRule($rule, $value, $path) {
|
||||
$match = null;
|
||||
if (!preg_match('#^'.$rule.'#', $path, $match)) {
|
||||
return array(null, null);
|
||||
}
|
||||
|
||||
if (!is_array($value)) {
|
||||
return array($value, $match);
|
||||
}
|
||||
|
||||
$path = substr($path, strlen($match[0]));
|
||||
foreach ($value as $srule => $sval) {
|
||||
list($controller, $data) = $this->tryRule($srule, $sval, $path);
|
||||
if ($controller) {
|
||||
return array($controller, $data + $match);
|
||||
}
|
||||
}
|
||||
|
||||
return array(null, null);
|
||||
}
|
||||
}
|
||||
10
src/aphront/mapper/__init__.php
Normal file
10
src/aphront/mapper/__init__.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
phutil_require_source('AphrontURIMapper.php');
|
||||
91
src/aphront/request/AphrontRequest.php
Normal file
91
src/aphront/request/AphrontRequest.php
Normal file
@@ -0,0 +1,91 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
class AphrontRequest {
|
||||
|
||||
const TYPE_AJAX = '__ajax__';
|
||||
const TYPE_FORM = '__form__';
|
||||
|
||||
private $host;
|
||||
private $path;
|
||||
private $requestData;
|
||||
|
||||
final public function __construct($host, $path) {
|
||||
$this->host = $host;
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
final public function setRequestData(array $request_data) {
|
||||
$this->requestData = $request_data;
|
||||
return $this;
|
||||
}
|
||||
|
||||
final public function getPath() {
|
||||
return $this->path;
|
||||
}
|
||||
|
||||
final public function getHost() {
|
||||
return $this->host;
|
||||
}
|
||||
|
||||
final public function getInt($name, $default = null) {
|
||||
if (isset($this->requestData[$name])) {
|
||||
return (int)$this->requestData[$name];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
final public function getStr($name, $default = null) {
|
||||
if (isset($this->requestData[$name])) {
|
||||
return (string)$this->requestData[$name];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
final public function getArr($name, $default = null) {
|
||||
if (isset($this->requestData[$name]) &&
|
||||
is_array($this->requestData[$name])) {
|
||||
return $this->requestData[$name];
|
||||
} else {
|
||||
return $default;
|
||||
}
|
||||
}
|
||||
|
||||
final public function getExists($name) {
|
||||
return array_key_exists($name, $this->requestData);
|
||||
}
|
||||
|
||||
final public function isHTTPPost() {
|
||||
return ($_SERVER['REQUEST_METHOD'] == 'POST');
|
||||
}
|
||||
|
||||
final public function isAjax() {
|
||||
return $this->getExists(self::TYPE_AJAX);
|
||||
}
|
||||
|
||||
final public function isFormPost() {
|
||||
return $this->getExists(self::TYPE_FORM) && $this->isHTTPPost();
|
||||
}
|
||||
|
||||
}
|
||||
10
src/aphront/request/__init__.php
Normal file
10
src/aphront/request/__init__.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
phutil_require_source('AphrontRequest.php');
|
||||
28
src/aphront/response/404/Aphront404Response.php
Normal file
28
src/aphront/response/404/Aphront404Response.php
Normal file
@@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
class Aphront404Response extends AphrontResponse {
|
||||
|
||||
public function buildResponseString() {
|
||||
return '404 Not Found';
|
||||
}
|
||||
|
||||
}
|
||||
12
src/aphront/response/404/__init__.php
Normal file
12
src/aphront/response/404/__init__.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/response/base');
|
||||
|
||||
|
||||
phutil_require_source('Aphront404Response.php');
|
||||
48
src/aphront/response/base/AphrontResponse.php
Normal file
48
src/aphront/response/base/AphrontResponse.php
Normal file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
abstract class AphrontResponse {
|
||||
|
||||
private $request;
|
||||
|
||||
public function setRequest($request) {
|
||||
$this->request = $request;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getRequest() {
|
||||
return $this->request;
|
||||
}
|
||||
|
||||
public function getHeaders() {
|
||||
return array();
|
||||
}
|
||||
|
||||
public function getCacheHeaders() {
|
||||
return array(
|
||||
array('Cache-Control', 'private, no-cache, no-store, must-revalidate'),
|
||||
array('Expires', 'Sat, 01 Jan 2000 00:00:00 GMT'),
|
||||
);
|
||||
}
|
||||
|
||||
abstract public function buildResponseString();
|
||||
|
||||
}
|
||||
10
src/aphront/response/base/__init__.php
Normal file
10
src/aphront/response/base/__init__.php
Normal file
@@ -0,0 +1,10 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
|
||||
phutil_require_source('AphrontResponse.php');
|
||||
35
src/aphront/response/dialog/AphrontDialogResponse.php
Normal file
35
src/aphront/response/dialog/AphrontDialogResponse.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
final class AphrontDialogResponse extends AphrontResponse {
|
||||
|
||||
private $dialog;
|
||||
|
||||
public function setDialog(AphrontDialogView $dialog) {
|
||||
$this->dialog = $dialog;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function buildResponseString() {
|
||||
return $this->dialog->render();
|
||||
}
|
||||
|
||||
}
|
||||
12
src/aphront/response/dialog/__init__.php
Normal file
12
src/aphront/response/dialog/__init__.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/response/base');
|
||||
|
||||
|
||||
phutil_require_source('AphrontDialogResponse.php');
|
||||
41
src/aphront/response/redirect/AphrontRedirectResponse.php
Normal file
41
src/aphront/response/redirect/AphrontRedirectResponse.php
Normal file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
class AphrontRedirectResponse extends AphrontResponse {
|
||||
|
||||
private $uri;
|
||||
|
||||
public function setURI($uri) {
|
||||
$this->uri = $uri;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getHeaders() {
|
||||
return array(
|
||||
array('Location', $this->uri),
|
||||
);
|
||||
}
|
||||
|
||||
public function buildResponseString() {
|
||||
return '';
|
||||
}
|
||||
|
||||
}
|
||||
12
src/aphront/response/redirect/__init__.php
Normal file
12
src/aphront/response/redirect/__init__.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/response/base');
|
||||
|
||||
|
||||
phutil_require_source('AphrontRedirectResponse.php');
|
||||
35
src/aphront/response/webpage/AphrontWebpageResponse.php
Normal file
35
src/aphront/response/webpage/AphrontWebpageResponse.php
Normal file
@@ -0,0 +1,35 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @group aphront
|
||||
*/
|
||||
class AphrontWebpageResponse extends AphrontResponse {
|
||||
|
||||
private $content;
|
||||
|
||||
public function setContent($content) {
|
||||
$this->content = $content;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function buildResponseString() {
|
||||
return $this->content;
|
||||
}
|
||||
|
||||
}
|
||||
12
src/aphront/response/webpage/__init__.php
Normal file
12
src/aphront/response/webpage/__init__.php
Normal file
@@ -0,0 +1,12 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'aphront/response/base');
|
||||
|
||||
|
||||
phutil_require_source('AphrontWebpageResponse.php');
|
||||
46
src/aphront/storage/lisk/AphrontLiskDAO.php
Normal file
46
src/aphront/storage/lisk/AphrontLiskDAO.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* Copyright 2011 Facebook, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
abstract class AphrontLiskDAO extends LiskDAO {
|
||||
|
||||
public function establishConnection($mode) {
|
||||
return new AphrontMySQLDatabaseConnection(
|
||||
array(
|
||||
'user' => 'root',
|
||||
'pass' => '',
|
||||
'host' => 'localhost',
|
||||
'database' => 'aphront_'.$this->getApplicationName(),
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
public function getTableName() {
|
||||
$class = strtolower(get_class($this));
|
||||
if (!strncmp($class, 'aphront', 7)) {
|
||||
$class = substr($class, 7);
|
||||
}
|
||||
$app = $this->getApplicationName();
|
||||
if (!strncmp($class, $app, strlen($app))) {
|
||||
$class = substr($class, strlen($app));
|
||||
}
|
||||
return $app.'_'.$class;
|
||||
}
|
||||
|
||||
abstract public function getApplicationName();
|
||||
}
|
||||
13
src/aphront/storage/lisk/__init__.php
Normal file
13
src/aphront/storage/lisk/__init__.php
Normal file
@@ -0,0 +1,13 @@
|
||||
<?php
|
||||
/**
|
||||
* This file is automatically generated. Lint this module to rebuild it.
|
||||
* @generated
|
||||
*/
|
||||
|
||||
|
||||
|
||||
phutil_require_module('aphront', 'storage/connection/mysql');
|
||||
phutil_require_module('aphront', 'storage/lisk/dao');
|
||||
|
||||
|
||||
phutil_require_source('AphrontLiskDAO.php');
|
||||
Reference in New Issue
Block a user