Permalink
Browse files

Improvements to configuration of complilers/bundlers. Added a text lo…

…cale translate alias.
  • Loading branch information...
1 parent 8aa66f4 commit b90f8e934a7bf34e920e0ebc40f32d2ea8c943ce @balupton balupton committed Nov 9, 2010
@@ -362,16 +362,18 @@ public function loadUserAcl ( $User = null, Zend_Acl $Acl = null ) {
foreach ( $Roles as $Role ) {
$roles[] = 'role-'.$Role->code;
}
- if ( !empty($roles) )
+ if ( !empty($roles) ) {
$Acl->addRole($AclUser, $roles);
+ }
# Add User Permissions to Acl
$Permissions = $User->Permissions; $permissions = array();
foreach ( $Permissions as $Permission ) {
$permissions[] = 'permission-'.$Permission->code;
}
- if ( !empty($permissions) )
+ if ( !empty($permissions) ) {
$Acl->allow($AclUser, $this->getDefaultResource(), $permissions);
+ }
# Add Role to Acl / Set Role
if ( !$Acl->hasRole($AclUser) ) {
@@ -401,6 +403,7 @@ public function loadAcl ( Zend_Acl $Acl = null ) {
# Add Roles to Acl
$Roles = Doctrine::getTable('Role')->createQuery()->select('r.code, rp.code')->from('Role r, r.Permissions rp')->setHydrationMode(Doctrine::HYDRATE_ARRAY)->execute();
+ $Resource = $this->getDefaultResource();
foreach ( $Roles as $Role ) {
$role = 'role-'.$Role['code'];
$AclRole = new Zend_Acl_Role($role);
@@ -409,7 +412,7 @@ public function loadAcl ( Zend_Acl $Acl = null ) {
foreach ( $Role['Permissions'] as $Permission ) {
$permissions[] = 'permission-'.$Permission['code'];
}
- $Acl->allow($AclRole, $this->getDefaultResource(), $permissions);
+ $Acl->allow($AclRole, $Resource, $permissions);
}
# Load the User Acl
@@ -430,9 +433,14 @@ public function hasAclEntry ( $role, $resource, $privilege, Zend_Acl $Acl = null
# Prepare
if ( empty($Acl) )
$Acl = $this->getAcl($Acl);
+ if ( empty($resource) )
+ $resource = $this->getDefaultResource();
# Check
$result = $Acl->isAllowed($role, $resource, $privilege);
+ if ( !$result && is_string($privilege) ) {
+ $result = $Acl->isAllowed($role, $resource, 'permission-'.$privilege);
+ }
# Return result
return $result;
@@ -446,6 +454,7 @@ public function hasAclEntry ( $role, $resource, $privilege, Zend_Acl $Acl = null
*/
public function hasPermission ( $resource, $privileges = null ) {
# Prepare
+ $result = false;
if ( $privileges === null ) {
// Shortcut simplified
$privileges = $resource;
@@ -457,12 +466,12 @@ public function hasPermission ( $resource, $privileges = null ) {
$Role = $this->getRole();
# Check
- if ( $Role && ($result = $this->hasAclEntry($Role, $resource, $privileges)) ) {
- return $result;
+ if ( $Role ) {
+ $result = $this->hasAclEntry($Role, $resource, $privileges);
}
- # Return false
- return false;
+ # Return $result
+ return $result;
}
@@ -745,6 +754,10 @@ public function updateUrlPaths ( ) {
# Apply Paths
$this->getUrl()->renege('paths',$paths);
+ # BaseUrl
+ $Controller = Zend_Controller_Front::getInstance();
+ $Controller->setBaseUrl($this->getBaseUrl());
+
# Chain
return $this;
}
View
@@ -703,5 +703,16 @@ public function float ( $number, $options = array() ) {
public function string ( ) {
$args = func_get_args();
return call_user_func_array(array($this,'translate'), $args);
+ }
+
+ /**
+ * Translate a string
+ * @param number $number
+ * @param array $options
+ * @return string
+ */
+ public function text ( ) {
+ $args = func_get_args();
+ return call_user_func_array(array($this,'translate'), $args);
}
}
@@ -118,8 +118,11 @@ public function render ( ) {
# Apply Details
if ( !$this->isFriendly() ) {
- $result .=
- '<pre class="details">'.htmlspecialchars(var_export($event['details'],true)).'</pre>';
+ ob_start();
+ var_dump($event['details']);
+ $_details = ob_get_contents();
+ ob_end_clean();
+ $result .= '<pre class="details">'.htmlspecialchars($_details).'</pre>';
}
# Finish event
@@ -126,6 +126,7 @@ protected function _performRequests ( ) {
$warnings = $node['value'];
break;
+ case 'serverErrors':
case 'errors':
$errors = $node['value'];
break;
@@ -155,7 +156,16 @@ protected function _performRequests ( ) {
}
if ( $errors ) {
- throw new Exception('Errors occurred when using the Google Closure Service: '.$errors);
+ $error = '';
+ if ( is_array($errors) ) {
+ foreach ( $errors as $_error ) {
+ $error .= $_error['value'];
+ }
+ }
+ else {
+ $error = $errors;
+ }
+ throw new Exception('Errors occurred when using the Google Closure Service: '.$error);
}
$return .= $code.' ';
Oops, something went wrong.

0 comments on commit b90f8e9

Please sign in to comment.