Skip to content

Loading…

Allow CUSTOM directory to be located anywhere #132

Merged
merged 2 commits into from

2 participants

@dshafik
The Frapi Project member

Allow setting of CUSTOM_PATH via a FRAPI_CUSTOM_PATH environment variable. Fixes #127

@helgi helgi merged commit cb2813a into frapi:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
View
2 src/frapi/admin/application/Bootstrap.php
@@ -45,7 +45,7 @@ protected function _initConfig()
{
Zend_Registry::set('config', new Zend_Config($this->getOptions()));
- $localConfigPath = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' .
+ $localConfigPath = CUSTOM_PATH .
DIRECTORY_SEPARATOR . 'Config' . DIRECTORY_SEPARATOR;
Zend_Registry::set('localConfigPath', $localConfigPath);
View
2 src/frapi/admin/application/modules/console/controllers/ActionController.php
@@ -193,7 +193,7 @@ public function syncAction()
{
$this->_helper->viewRenderer->setViewSuffix('txt');
- $dir = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'Action';
+ $dir = CUSTOM_PATH . DIRECTORY_SEPARATOR . 'Action';
if (!is_writable($dir)) {
$this->view->message = $this->tr->_('ACTION_WRITE_ERROR', $dir) . PHP_EOL;
View
6 src/frapi/admin/application/modules/default/controllers/ActionController.php
@@ -140,7 +140,7 @@ public function codeAction()
$name = $actionData['name'];
$file = strtolower($name) . '.php';
- $dir = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'Action';
+ $dir = CUSTOM_PATH . DIRECTORY_SEPARATOR . 'Action';
$file = $dir . DIRECTORY_SEPARATOR . ucfirst($file);
if ($this->_request->isPost()) {
@@ -263,7 +263,7 @@ public function syncAction()
$this->_helper->viewRenderer->setNoRender();
$model = new Default_Model_Action;
- $dir = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'Action';
+ $dir = CUSTOM_PATH . DIRECTORY_SEPARATOR . 'Action';
if (!is_writable($dir)) {
$this->addMessage(sprintf($this->tr->_('ACTION_WRITE_ERROR'), $dir));
$this->_redirect('/action');
@@ -276,7 +276,7 @@ public function syncAction()
public function testAction()
{
$name = 'Testing1';
- $dir = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'Action';
+ $dir = CUSTOM_PATH . DIRECTORY_SEPARATOR . 'Action';
$file = $dir . DIRECTORY_SEPARATOR . $name . '.php';
require_once $file;
View
10 src/frapi/admin/application/modules/default/controllers/IndexController.php
@@ -27,7 +27,7 @@ public function init($styles = array())
/**
* Index action
*
- * The main index does nothing special. it verifies whether or not the
+ * The main index does nothing special. it verifies whether or not the
* setup can be ran by verifying the permissions on the custom directory
* emits meesages when it's not.
*
@@ -39,13 +39,13 @@ public function indexAction()
$user = get_current_user();
$dir = Zend_Registry::get('localConfigPath');
-
+
if (!is_writable($dir)) {
$configPathMessage = $this->tr->_('ACTION_WARNING_CONFIG');
$issues['config-path'] = sprintf($configPathMessage, $dir, $user);
}
-
- $dir = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'Action';
+
+ $dir = CUSTOM_PATH . DIRECTORY_SEPARATOR . 'Action';
if (!is_writable($dir)) {
$actionPathMessage = $this->tr->_('ACTION_WARNING_ACTION');
@@ -53,6 +53,6 @@ public function indexAction()
}
$this->view->issues = $issues;
-
+
}
}
View
2 src/frapi/admin/application/modules/default/models/Action.php
@@ -342,7 +342,7 @@ public function sync()
}
$name = ucfirst(strtolower($a['name']));
- $dir = ROOT_PATH . DIRECTORY_SEPARATOR . 'custom' . DIRECTORY_SEPARATOR . 'Action';
+ $dir = CUSTOM_PATH . DIRECTORY_SEPARATOR . 'Action';
$file = $dir . DIRECTORY_SEPARATOR . $name . '.php';
View
14 src/frapi/admin/application/modules/default/models/Output.php
@@ -16,15 +16,15 @@
class Default_Model_Output extends Lupin_Model
{
protected $config;
-
+
public function __construct()
{
$this->config = new Lupin_Config_Xml('outputs');
}
-
+
public function sync()
{
- $path = ROOT_PATH . '/library/Frapi/Output/';
+ $path = LIBRARY_ROOT_PATH . DIRECTORY_SEPARATOR . 'Output' . DIRECTORY_SEPARATOR;
$dir = new DirectoryIterator($path);
$data = array();
foreach ($dir as $d) {
@@ -63,7 +63,7 @@ public function makeDefault($id)
try {
$this->config->update('output', 'name', $id, array('default' => '1'));
} catch (Exception $e) {}
-
+
$this->refreshAPCCache();
}
@@ -79,7 +79,7 @@ public function enable($id)
try {
$this->config->update('output', 'name', $id, array('enabled' => '1'));
} catch (Exception $e) {}
-
+
$this->refreshAPCCache();
}
@@ -89,7 +89,7 @@ public function disable($id)
try {
$this->config->update('output', 'name', $id, array('enabled' => '0'));
} catch (Exception $e) {}
-
+
$this->refreshAPCCache();
}
@@ -103,7 +103,7 @@ public function refreshAPCCache()
$configModel = new Default_Model_Configuration();
$server = $configModel->getKey('api_url');
$hash = isset($server) ? hash('sha1', $server) : '';
-
+
$cache = Frapi_Cache::getInstance(FRAPI_CACHE_ADAPTER);
$cache->delete($hash . '-Output.default-format');
View
3 src/frapi/library/Frapi/AllFiles.php
@@ -19,7 +19,8 @@
define('ROOT_PATH', dirname(dirname(dirname(__FILE__))));
}
-define('CUSTOM_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'custom');
+define('DEFAULT_CUSTOM_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'custom');
+define('CUSTOM_PATH', (!isset($_SERVER['FRAPI_CUSTOM_PATH']) || !file_exists($_SERVER['FRAPI_CUSTOM_PATH'])) ? DEFAULT_CUSTOM_PATH : $_SERVER['FRAPI_CUSTOM_PATH']);
define('LIBRARY_ROOT_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR . 'Frapi');
define('EXTRA_LIBRARIES_ROOT_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . 'library' . DIRECTORY_SEPARATOR);
Something went wrong with that request. Please try again.