Skip to content

Commit

Permalink
Fixes for new BalCMS Structure.
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Oct 3, 2010
1 parent c5f4f1a commit 90467d7
Show file tree
Hide file tree
Showing 11 changed files with 120 additions and 34 deletions.
Empty file added .gitignore
Empty file.
Empty file added .htaccess
Empty file.
3 changes: 3 additions & 0 deletions Makefile
Expand Up @@ -26,3 +26,6 @@ tests:

report:
open $(DIRTESTS)/log/report/index.html

add:
git add .gitignore .htaccess * ;
69 changes: 66 additions & 3 deletions lib/Bal/App.php
Expand Up @@ -232,7 +232,7 @@ public function setup ( ) {
"$cwd ",
// Writeable Files
"chmod -R 777 ".
"$cwd/application/data/dump $cwd/application/data/schema ".
"$cwd/application/data/dump $cwd/application/data/schema $cwd/application/data/database/*.db ".
"$cwd/application/models $cwd/application/models/*.php $cwd/application/models/Base $cwd/application/models/Base/*.php ".
"$cwd/public/media/deleted $cwd/public/media/images $cwd/public/media/invoices $cwd/public/media/uploads ".
"$cwd/application/data/logs $cwd/application/data/logs/payment ".
Expand Down Expand Up @@ -278,8 +278,8 @@ public function setup ( ) {
echo '- [media-clean] -'."\n";
echo 'Media: Cleaning Media'."\n";
# Delete the contents of media dirs; uploads and images
$images_path = IMAGES_PATH;
$upload_path = UPLOADS_PATH;
$images_path = MEDIA_IMAGES_PATH;
$upload_path = MEDIA_UPLOADS_PATH;

# Check
if ( empty($images_path) ) {
Expand Down Expand Up @@ -616,6 +616,69 @@ static public function getActionControllerView ( ) {
return self::getView();
}

/**
* Generates a Zend_Config object from a data file
*/
static public function parseConfigFile ( $file ) {
# Fetch
$Config = self::parseDataFile($file);

# Check
if ( $Config ) {
$Config = new Zend_Config($Config);
}

# Return Config
return $Config;
}

/**
* Takes in a file path and attempts to loads it's contents using a series of supported types.
*/
static public function parseDataFile ( $file ) {
# Prepare
$Config = null;

# Check location exists
if ( is_readable($file) ) {
# Load Config
$extension = get_extension($file);
switch ( $extension ) {
# JSON
case 'js':
case 'json':
$Config = Zend_Json::decode(file_get_contents($file), Zend_Json::TYPE_ARRAY);
break;

# YAML
case 'yml':
case 'yaml':
$Config = sfYaml::load($file);
break;

# AUTO-DETECT
case '':
# We want to try the different extensions
$extensions = array('yaml','yml','json','js');
foreach ( $extensions as $extension ) {
$Config = self::parseDataFile($file.'.'.$extension);
if ( $Config ) {
break;
}
}
break;

# FAILURE
default:
throw new Zend_Exception('An unsupported data file type was passed to Bal_App::parseDataFile('.$file.')');
break;
}
}

# Return Config
return $Config;
}

static public function getView ( $clone = false ) {
# Prepare
$View = null;
Expand Down
18 changes: 10 additions & 8 deletions lib/Bal/Bootstrap.php
Expand Up @@ -174,7 +174,7 @@ protected function _initRoutes ( ) {
$this->bootstrap('autoload');

# Config
$routeConfig = sfYaml::load(CONFIG_PATH.'/routes.yaml');
$routeConfig = sfYaml::load(ROUTES_FILE_PATH);
$routeConfig = new Zend_Config($routeConfig[APPLICATION_ENV]);

# Route
Expand Down Expand Up @@ -371,6 +371,7 @@ protected function _initDoctrine ( ) {

# Config
$applicationConfig = Zend_Registry::get('applicationConfig');
$dsn = $applicationConfig['data']['connection_string'];
$extensions_path = $applicationConfig['data']['extensions_path'];
$models_path = $applicationConfig['data']['models_path'];
$autoloader = $applicationConfig['data']['autoloader'];
Expand Down Expand Up @@ -446,11 +447,12 @@ protected function _initDoctrine ( ) {
//$manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver);


# Prepare Connection
$dsn = $applicationConfig['data']['connection_string'];
$unix_socket = ini_get('mysql.default_socket');
if ( $unix_socket ) {
$dsn .= ';unix_socket=' . $unix_socket;
# Prepare MySQL Connection by Attaching Socket to DSN
if ( strstr($dsn,'mysql') && !strstr($dsn,'unix_socket=') ) {
$unix_socket = ini_get('mysql.default_socket');
if ( $unix_socket ) {
$dsn .= ';unix_socket=' . $unix_socket;
}
}

# Create Connection
Expand Down Expand Up @@ -553,8 +555,8 @@ protected function _initBalcms ( ) {
$View->addScriptPath(APPLICATION_PATH . '/modules/balcms/views/scripts');

# Widgets
if ( array_key_exists('widget', $applicationConfig) )
$View->getHelper('widget')->addWidgets($applicationConfig['widget']);
if ( array_key_exists('widgets', $applicationConfig) )
$View->getHelper('widget')->addWidgets($applicationConfig['widgets']['widget']);

# Return true
return true;
Expand Down
12 changes: 4 additions & 8 deletions lib/Bal/Controller/Action/Helper/App.php
Expand Up @@ -57,16 +57,12 @@ public function applyNavigation ( ) {

# Navigation
$nav_path = $module_config_path . '/nav.json';
if ( is_readable($nav_path) ) {
$NavData = file_get_contents($nav_path);
$NavData = Zend_Json::decode($NavData, Zend_Json::TYPE_ARRAY);
}
$NavData = Bal_App::parseDataFile($nav_path);

# Navigation Override
$nav_override_path = $config_path . '/nav.json';
if ( is_readable($nav_override_path) ) {
$NavDataOver = file_get_contents($nav_override_path);
$NavDataOver = Zend_Json::decode($NavDataOver, Zend_Json::TYPE_ARRAY);
$nav_override_path = NAVIGATION_FILE_PATH;
$NavDataOver = Bal_App::parseDataFile($nav_override_path);
if ( !empty($NavDataOver) ) {
$NavDataOver = delve($NavDataOver,$module);
if ( !empty($NavDataOver) ) {
$NavData = array_merge_recursive_keys($NavData, $NavDataOver);
Expand Down
29 changes: 23 additions & 6 deletions lib/Bal/Controller/Plugin/Url.php
Expand Up @@ -396,10 +396,18 @@ protected function getItem ( $table, $item ) {
* @return this
*/
public function map ( $map ) {
$Route = delve($map,'Route');
if ( !$Route )
if ( array_key_exists('path', $map) ) {
$Route = delve($map,'Route',delve($map,'Map'));
if ( !$Route ) {
$pathColumn = Bal_App::getConfig('routing.defaults.pathColumn','path');
if ( delve($map,$pathColumn) ) {
$Route = $map;
}
else {
throw new Bal_Exception(array(
'Could not resolve the Map',
'map' => is_object($map) ? get_class($map) : $map
));
}
}
return $this->route('map')->param('Map',$Route);
}
Expand Down Expand Up @@ -469,9 +477,18 @@ public function item ( $Item, $param = null, $error = true ) {
/**
* @alias self::file
*/
public function content ( $Item ) {
if ( is_string($Item) ) {
$Item = $this->getItem('Content',$Item);
public function content ( $input ) {
if ( is_string($input) ) {
$Item = $this->getItem('Content',$input);
}
else {
$Item = $input;
}
if ( !delve($Item,'id') ) {
throw new Bal_Exception(array(
'Could not resolve the Content Item',
'input' => $input
));
}
return $this->map($Item);
}
Expand Down
4 changes: 2 additions & 2 deletions lib/Bal/Controller/Router/Route/Map.php
Expand Up @@ -71,12 +71,12 @@ public static function getInstance ( Zend_Config $config ) {
}

protected function _getOptions ( ) {
$options = $GLOBALS['Application']->getOption('bal');
$options = $options['routing'];
$options = $GLOBALS['Application']->getOption('routing');
return $options;
}

protected function _getDefaults ( $prefix = array(), $postfix = array() ) {
if ( empty($prefix) ) $prefix = array(); // if $prefix is set to NULL, it does not default to array() - how that makes sense only flying pigs know
$defaults = $this->_getMappedValues($this->_defaults, true, false);
return array_merge($prefix, $defaults, $postfix);
}
Expand Down
5 changes: 3 additions & 2 deletions lib/Bal/Doctrine/Core.php
Expand Up @@ -1399,7 +1399,8 @@ public static function ensure ( Doctrine_Event $Event, $Event_type, array $check

# Ensure
foreach ( $checks as $check ) {
$ensure[] = $Invoker->$check($Event,$Event_type);
$result = $Invoker->$check($Event,$Event_type);
$ensure[] = $result;
}

# Result
Expand Down Expand Up @@ -1530,7 +1531,7 @@ public static function ensureTags ( Doctrine_Event $Event, $tagRelation, $tagFie
$Invoker->$tagRelation = $tagsUser;

# Save
$save = true;
// $save = true;
}
}

Expand Down
2 changes: 1 addition & 1 deletion lib/Bal/Locale.php
Expand Up @@ -216,7 +216,7 @@ public function getFile ( $locale = null ) {
if ( $locale === null ) $locale = $this->getLocale();

# Determine
$file = $this->il8n_path . DIRECTORY_SEPARATOR . $locale . '.yaml';
$file = $this->il8n_path . DIRECTORY_SEPARATOR . $locale . '.yml';

# Return
return $file;
Expand Down
12 changes: 8 additions & 4 deletions lib/Bal/View/Helper/App.php
Expand Up @@ -60,7 +60,9 @@ function __call ( $method, $args ) {
public function getNavigation ( $code ) {
# Prepare
$NavigationMenu = delve($this->view,'Navigation.'.$code);
if ( !$NavigationMenu ) throw new Zend_Exception('Could not find Navigation Menu: '.$code);
if ( !$NavigationMenu ) {
throw new Zend_Exception('Could not find Navigation Menu: '.$code);
}

# Return
return $NavigationMenu;
Expand All @@ -76,7 +78,9 @@ public function getNavigationMenu ( $code ) {
}
else {
$NavigationMenu = $this->getNavigation($code);
if ( !$NavigationMenu ) throw new Zend_Exception('Could not find Navigation Menu: '.$code);
if ( !$NavigationMenu ) {
throw new Zend_Exception('Could not find Navigation Menu: '.$code);
}
}

# Render
Expand Down Expand Up @@ -349,7 +353,7 @@ public function headScript ( array $options = array() ) {
case 'testing':
case 'development':
default:
$jquery_sparkle_url = '/repos/jquery-sparkle';
$jquery_sparkle_url = '/javascript/jquery-sparkle';
break;
}
$headScript->offsetSetFile($jquery_sparkle, $jquery_sparkle_url.'/scripts/jquery.sparkle'.(APPLICATION_ENV === 'production' ? '.min' : '').'.js');
Expand All @@ -372,7 +376,7 @@ public function headScript ( array $options = array() ) {
case 'testing':
case 'development':
default:
$jquery_ajaxy_url = '/repos/jquery-ajaxy';
$jquery_ajaxy_url = '/javascript/jquery-ajaxy';
break;
}
// Include
Expand Down

0 comments on commit 90467d7

Please sign in to comment.