Skip to content
Browse files

Merge branch 'develop'

  • Loading branch information...
2 parents 67f4bdb + 166cb16 commit cd702f6ff80860195f43727e5cd3f048e3732ea0 @simonbingham committed
View
3 Application.cfc
@@ -33,6 +33,7 @@ component extends="frameworks.org.corfield.framework"{
}
// ------------------------ FW/1 SETTINGS ------------------------ //
+
variables.framework = {
cacheFileExists = !this.development
, defaultSubsystem = "public"
@@ -169,7 +170,7 @@ component extends="frameworks.org.corfield.framework"{
, resetpasswordemailsubject = ""
, whitelist = "^admin:security,^public:" // list of unsecure actions - by default all requests require authentication
}
- , version = "2012.09.28"
+ , version = "2012.10.5"
};
// override config in development mode
if( config.development ){
View
15 _tests/model/content/TestContentGateway.cfc
@@ -31,9 +31,14 @@ component extends="mxunit.framework.TestCase"{
}
function testGetChildren(){
- var result = CUT.getChildren( 1, 26, true );
- assertEquals( 3, result.recordcount );
- }
+ var result = CUT.getChildren( left=1, right=18 );
+ assertEquals( 2, result.recordcount ); // note: 2 as only returns direct descendants
+ }
+
+ function testGetChildrenClearCache(){
+ var result = CUT.getChildren( left=1, right=18,clearcache=true );
+ assertEquals( 2, result.recordcount );
+ }
function testGetNavigation(){
var result = CUT.getNavigation();
@@ -146,6 +151,10 @@ component extends="mxunit.framework.TestCase"{
result = ArrayLen( pages );
assertEquals( 14, result );
}
+
+ function testShiftPages(){
+ CUT.ShiftPages( affectedpages="1,2,3", shift=0 );
+ }
// ------------------------ IMPLICIT ------------------------ //
View
14 _tests/model/content/TestContentService.cfc
@@ -15,11 +15,17 @@ component extends="mxunit.framework.TestCase"{
}
function testGetChildren(){
- var Page = CUT.getPage( 1 );
- var result = CUT.getChildren( Page, true );
- assertEquals( 3, result.RecordCount );
+ var Page = mock().getLeftValue().returns( 1 ).getRightValue().returns( 18 );
+ var result = CUT.getChildren( Page );
+ assertEquals( 2, result.recordcount );
}
-
+
+ function testGetChildrenClearCache(){
+ var Page = mock().getLeftValue().returns( 1 ).getRightValue().returns( 18 );
+ var result = CUT.getChildren( Page=Page, clearcache=true );
+ assertEquals( 2, result.recordcount );
+ }
+
function testGetPageWherePageDoesNotExist(){
var Page = CUT.getPage( 14 );
var result = Page.isPersisted();
View
2 _tests/selenium/Tests.cfc
@@ -123,7 +123,7 @@ component extends="mxunit.framework.TestCase"{
selenium.waitForPageToLoad( timeout );
assertTrue( selenium.isTextPresent( "regexp:(The page "".*"" has been saved.)" ) );
// delete page
- selenium.click( "//div[@id='content']/table/tbody/tr[10]/td[5]/a/i" );
+ selenium.click( "//div[@id='content']/table/tbody/tr[10]/td[6]/a/i" );
selenium.waitForPageToLoad( timeout );
// when we delete a record a confirmation dialog appears
// calling the getConfirmation method forces the Ok button to be clicked in the dialog
View
3 admin/controllers/security.cfc
@@ -44,8 +44,7 @@ component accessors="true"{
void function resetpassword( required struct rc ){
param name="rc.username" default="";
rc.result = variables.SecurityService.resetPassword( rc, rc.config.name, rc.config.security, "../../admin/views/security/email.cfm" );
- if( rc.result.getIsSuccess() ) variables.fw.redirect( "security", "result" );
- else variables.fw.redirect( "security.password", "result" );
+ variables.fw.redirect( "security.password", "result" );
}
}
View
5 admin/views/pages/default.cfm
@@ -12,8 +12,7 @@
<th>Last Updated</th>
<th class="center">View</th>
<cfif rc.config.page.enableadddelete><th class="center">Add Page</th></cfif>
- <!--- temporarily disabled sorting of pages until bug is fixed - https://github.com/simonbingham/xindi/issues/101 --->
- <!---<th class="center">Sort Sub Pages</th>--->
+ <th class="center">Sort Sub Pages</th>
<cfif rc.config.page.enableadddelete><th class="center">Delete</th></cfif>
</tr>
</thead>
@@ -32,7 +31,7 @@
<td title="last updated on #DateFormat( rc.navigation.updated, 'medium' )# at #TimeFormat( rc.navigation.updated, 'HH:MM' )#">#getTimeInterval( rc.navigation.updated )# by # rc.navigation.updatedby#</td>
<td class="center"><a href="#buildURL( action="public:" & rc.navigation.slug )#" title="View" target="_blank"><i class="icon-eye-open"></i></a></td>
<cfif rc.config.page.enableadddelete><td class="center"><cfif rc.navigation.depth lt rc.config.page.maxlevels and !ListFind( rc.config.page.suppressaddpage, rc.navigation.pageid )><a href="#buildURL( action='pages.maintain', querystring='ancestorid/#rc.navigation.pageid#' )#" title="Add Page"><i class="icon-plus-sign"></i></a></cfif></td></cfif>
- <!---<td class="center"><cfif rc.navigation.descendants gt 1><a href="#buildURL( action='pages.sort', querystring='pageid/#rc.navigation.pageid#' )#" title="Sort"><i class="icon-retweet"></i></a></cfif></td>--->
+ <td class="center"><cfif rc.navigation.descendants gt 1><a href="#buildURL( action='pages.sort', querystring='pageid/#rc.navigation.pageid#' )#" title="Sort"><i class="icon-retweet"></i></a></cfif></td>
<cfif rc.config.page.enableadddelete><td class="center"><cfif rc.navigation.descendants eq 0 and !ListFind( rc.config.page.suppressdeletepage, rc.navigation.pageid )><a href="#buildURL( 'pages.delete' )#/pageid/#rc.navigation.pageid#" title="Delete"><i class="icon-remove"></i></a></cfif></td></cfif>
</tr>
</cfloop>
View
0 .../ico/apple-touch-icon-114-precomposed.png → apple-touch-icon-114-precomposed.png
File renamed without changes
View
0 ...s/ico/apple-touch-icon-57-precomposed.png → apple-touch-icon-57-precomposed.png
File renamed without changes
View
0 ...s/ico/apple-touch-icon-72-precomposed.png → apple-touch-icon-72-precomposed.png
File renamed without changes
View
15 frameworks/hoth/test/Application.cfc
@@ -1,15 +0,0 @@
-<!---
- Aaron Greenlee
- http://aarongreenlee.com/
-
- This work is licensed under a Creative Commons Attribution-Share-Alike 3.0
- Unported License.
-
- // Original Info -----------------------------------------------------------
- Author : Aaron Greenlee
- Created : 10/01/2010
-
---->
-<cfcomponent output="false">
- <cfset this.name = "Hoth Tests_" & hash(getCurrentTemplatePath())>
-</cfcomponent>
View
39 frameworks/hoth/test/HothConfig.cfc
@@ -1,39 +0,0 @@
-/**
- Aaron Greenlee
- http://aarongreenlee.com/
-
- This work is licensed under a Creative Commons Attribution-Share-Alike 3.0
- Unported License.
-
- // Original Info -----------------------------------------------------------
- Author : Aaron Greenlee
- Created : 10/01/2010
-
- Unit Test Config for Hoth
-
- // Modifications :---------------------------------------------------------
- Modified : 12/13/2010 9:52:41 AM by Aaron Greenlee.
- - Now supporting ColdBox 3.0 RC1
- Modified : 02/18/2011 1:20:12 PM by Aaron Greenlee.
- - Now supporting the HothReportURL value.
-*/
-component
- implements='Hoth.object.iHothConfig'
- extends='Hoth.object.CoreConfig'
- accessors=true {
-
- property name='applicationName' default='HothUnitTests';
- property name='timeToLock' default='1';
- property name='logPath' default='/Hoth/test/logs';
- property name='EmailNewExceptions' default='true';
- property name='EmailNewExceptionsTo' default='aarongreenlee@gmail.com';
- property name='EmailNewExceptionsFrom' default='aarongreenlee@gmail.com';
- property name='EmailNewExceptionsFile' default='true';
- property name='HothReportURL' default='UNIT_TEST_WILL_POPULATE';
-
- public function init ()
- {
- super.init();
- return this;
- }
-}
View
15 frameworks/hoth/test/facade/RemoteFacade.cfc
@@ -1,15 +0,0 @@
-/**
- Aaron Greenlee
- http://aarongreenlee.com/
-
- This work is licensed under a Creative Commons Attribution-Share-Alike 3.0
- Unported License.
-
- // Original Info -----------------------------------------------------------
- Author : Aaron Greenlee
- Created : 10/01/2010
-
- MXUnit Remote Facade
-
-*/
-component extends='mxunit.framework.RemoteFacade' {}
View
144 frameworks/hoth/test/unit/HothApplicationManagerTest.cfc
@@ -1,144 +0,0 @@
-/**
- Aaron Greenlee
- http://aarongreenlee.com/
-
- This work is licensed under a Creative Commons Attribution-Share-Alike 3.0
- Unported License.
-
- // Original Info -----------------------------------------------------------
- Author : Aaron Greenlee
- Created : 12/13/2010 10:17:31 AM
-
- Unit Test for HothApplicationManager
-
- // Modifications :---------------------------------------------------------
-
-*/
-
-/** Unit test for Hoth.HothTracker */
-component extends="mxunit.framework.TestCase"
-{
-
- variables.testDB = '/Hoth/test/db/';
- variables.appFile = expandPath(variables.testDB & 'applications.hoth');
-
- /** Constructor */
- public void function setUp()
- {
- // Load our test config
- HothConfig = new Hoth.test.HothConfig();
- HothConfig.setGlobalDatabasePath(variables.testDB);
-
- // Change the global settings for the test
- HothConfig.GlobalHothSettings.globalDatabase = variables.testDB;
-
- // Create our SUT
- HothApplicationManager =
- new Hoth.object.HothApplicationManager(HothConfig);
-
- // Write our test application data
- local.applicationToSave =
- [{
- 'applicationName' = 'HothUnitTestFake'
- ,'logPath' = '/Hoth/test/logs_not_real'
- ,'created' = 0
- }];
- fileWrite(
- variables.appFile
- ,serializeJSON(local.applicationToSave)
- ,'UTF-8'
- );
-
- return;
- }
-
- /** Ensure our test db directory exists. **/
- public void function beforeTests ()
- {
- if (!directoryExists(variables.testDB))
- directoryCreate(variables.testDB);
-
- return;
- }
-
- /** Delete our test db file. **/
- public void function afterTests ()
- {
- // Delete test db unless a test triggered the delete
- if (fileExists(variables.appFile))
- {
- fileDelete(variables.appFile);
- }
- }
-
- // -------------------------------------------------------------------------
- /** Ensure we can read our application database file. **/
- public void function loadApplicationsFromDisk()
- {
- makePublic(HothApplicationManager, 'loadApplicationsFromDisk');
-
- // Confirm we have our application created in beforeTests();
- local.appsFound = arrayLen(
- HothApplicationManager.loadApplicationsFromDisk(HothConfig)
- );
-
- assertEquals(
- 1
- ,local.appsFound
- ,'Invalid application db.'
- );
-
- return;
- }
-
- /** Ensure we delete an invalid application database file. **/
- public void function loadApplicationsFromDisk_Deletes_Invalid_JSON()
- {
- makePublic(HothApplicationManager, 'loadApplicationsFromDisk');
-
- // Save invalid data and expect the file to be deleted
- fileWrite(
- variables.appFile
- ,'I am not JSON'
- ,'UTF-8'
- );
-
- // Now, we expect zero.
- local.appsFound = arrayLen(
- HothApplicationManager.loadApplicationsFromDisk(HothConfig)
- );
-
- assertEquals(
- 0
- ,local.appsFound
- ,'Should have deleted the file and returned zero.'
- );
-
- assert(
- fileExists(variables.testDB & variables.appFile) == false
- ,'Should have deleted the file and returned zero.'
- );
-
- return;
- }
-
- /** Ensure we can learn about our applications. **/
- public void function learnApplication()
- {
-
- local.newApplication =
- HothApplicationManager.learnApplication(HothConfig);
-
- assert(local.newApplication, 'We should have a new application.');
-
- // Performing the same test twice should now return false since we
- // already know about this application.
-
- local.newApplication =
- HothApplicationManager.learnApplication(HothConfig);
-
- assertFalse(local.newApplication, 'We should NOT have a new application.');
-
- return;
- }
-}
View
42 frameworks/hoth/test/unit/HothConfigTest.cfc
@@ -1,42 +0,0 @@
-/**
- Aaron Greenlee
- http://aarongreenlee.com/
-
- This work is licensed under a Creative Commons Attribution-Share-Alike 3.0
- Unported License.
-
- // Original Info -----------------------------------------------------------
- Author : Aaron Greenlee
- Created : 12/13/2010 10:17:31 AM
-
- Unit Test for Hoth Config Object.
-
- // Modifications :---------------------------------------------------------
-
-*/
-
-/** Unit test for Hoth.HothTracker */
-component extends="mxunit.framework.TestCase"
-{
-
- /** Constructor */
- public void function setUp()
- {
- // Load our test config
- HothConfig = new Hoth.test.HothConfig();
-
- return;
- }
-
- // -------------------------------------------------------------------------
- public void function Confirm_Default_Storage() {
- // Confirm the global settings themselves
- assertEquals(
- '/Hoth/db/'
- ,HothConfig.getGlobalDatabasePath()
- ,'Has the default location to store application knowledge changed?'
- );
-
- return;
- }
-}
View
51 frameworks/hoth/test/unit/HothReporterTest.cfc
@@ -1,51 +0,0 @@
-/**
- Aaron Greenlee
- http://aarongreenlee.com/
-
- This work is licensed under a Creative Commons Attribution-Share-Alike 3.0
- Unported License.
-
- // Original Info -----------------------------------------------------------
- Author : Aaron Greenlee
- Created : 02/18/2011
-
- Unit Test for HothReporter
-
- // Modifications :---------------------------------------------------------
-*/
-
-import coldbox.system.testing.*;
-
-/** Unit test for Hoth.HothTracker */
-component extends="mxunit.framework.TestCase" {
-
- /** Constructor */
- public void function setUp() {
- MockBox = new MockBox();
-
- // Load our test config
- UnitTestHothConfig = new Hoth.test.HothConfig();
- UnitTestHothConfig.setHothReportURL('UNIT_TEST_EXPECTED_VALUE');
-
- // SUT
- SUT = new Hoth.HothReporter(UnitTestHothConfig);
-
- return;
- }
-
- // ------------------------------------------------------------------------------
- /** Test default ColdFusion exception tracking. */
- public void function getReportView() {
-
- local.view = SUT.getReportView();
- writeDump(var=local.view,output='c:\web\debug.log');
-
- local.position = find('UNIT_TEST_EXPECTED_VALUE',local.view,1);
-
- assert(
- local.position > 0
- ,'The configured URL was not inserted within the report HTML.'
- );
- return;
- }
-}
View
126 frameworks/hoth/test/unit/HothTrackerTest.cfc
@@ -1,126 +0,0 @@
-/**
- Aaron Greenlee
- http://aarongreenlee.com/
-
- This work is licensed under a Creative Commons Attribution-Share-Alike 3.0
- Unported License.
-
- // Original Info -----------------------------------------------------------
- Author : Aaron Greenlee
- Created : 10/01/2010
-
- Unit Test for HothTracker
-
- // Modifications :---------------------------------------------------------
- Modified : 12/13/2010 9:52:41 AM by Aaron Greenlee.
- - Now supporting ColdBox 3.0 RC1
-*/
-
-import coldbox.system.testing.*;
-
-/** Unit test for Hoth.HothTracker */
-component extends="mxunit.framework.TestCase" {
-
- /** Constructor */
- public void function setUp() {
- MockBox = new MockBox();
-
- // Load our test config
- HothConfig = new Hoth.test.HothConfig();
-
- variables.paths =
- {
- exceptions = HothConfig.getPath('exceptions')
- ,incidents = HothConfig.getPath('incidents')
- };
-
- // SUT
- variables.HothTracker = MockBox
- .createMock(classname='Hoth.HothTracker',callLogging=true)
- .init(HothConfig);
-
- // Delete all previous logs
- local.files = directoryList(variables.paths.exceptions,false,'path','*','size desc');
- if (!arrayIsEmpty(local.files))
- for (local.f in local.files)
- fileDelete(local.f);
-
- // Delete all previous logs
- local.files = directoryList(variables.paths.incidents,false,'path','*','size desc');
- if (!arrayIsEmpty(local.files))
- for (local.f in local.files)
- fileDelete(local.f);
-
- return;
- }
-
- // ------------------------------------------------------------------------------
- /** Test default ColdFusion exception tracking. */
- public void function track() {
- try {
- coldfusion = undefinedVariable;
- } catch (any exception) {
- local.hashOfStack = hash(lcase(exception.stacktrace),'SHA');
- local.HothOk = variables.HothTracker.track(exception);
-
- }
-
- local.file = local.hashOfStack & '.log';
- // Verify an exception was saved.
- assert( fileExists(variables.paths.exceptions & '/' & local.file), 'Expected #local.hashOfStack#.log exception file.');
- assert( fileExists(variables.paths.incidents & '/' & local.file), 'Expected #local.hashOfStack#.log incident file.');
-
- return;
- }
- /** Test a ColdBox exception. */
- public void function trackForColdBox() {
- try {
- coldbox = undefinedVariable;
- } catch (any exception) {
- local.ExceptionBean = new coldbox.system.web.context.ExceptionBean(errorStruct=exception);
- local.hashOfStack = hash(lcase(exception.stacktrace),'SHA');
- local.HothOk = variables.HothTracker.track(exception);
- }
- local.file = local.hashOfStack & '.log';
- // Verify an exception was saved.
- assert( fileExists(variables.paths.exceptions & '/' & local.file), 'Expected #local.hashOfStack#.log exception file.');
- assert( fileExists(variables.paths.incidents & '/' & local.file), 'Expected #local.hashOfStack#.log incident file.');
-
- return;
- }
-
- public void function trackDuplicates() {
- local.loops = 5;
-
- // Hit the same exception X times.
- for (local.i=1; local.i <= local.loops; local.i++) {
- try {
- apples = undefinedVariable2;
- } catch (any exception) {
- local.hashOfStack = hash(lcase(exception.stacktrace),'SHA');
- variables.HothTracker.track(exception);
- }
- }
- local.file = local.hashOfStack & '.log';
- // Verify an exception was saved.
- assert( fileExists(variables.paths.exceptions & '/' & local.file), 'Expected #local.hashOfStack#.log exception file.');
-
- // Verify our incident file was saved
- local.incidentFile = variables.paths.incidents & '/' & local.file;
- assert( fileExists(local.incidentFile), 'Expected #local.file# incident file.');
-
- // Verify our incident file has five incidents (one per line)
- local.incidents = FileOpen(local.incidentFile, 'read');
- local.lines = 0;
- while( !FileisEOF(local.incidents) ) {
- ++local.lines;
- local.line = FileReadLine(local.incidents);
- assert( isDate(local.line) , 'Expected date; Received "#local.line#"');
- }
- FileClose(local.incidents);
-
- assert(local.lines == local.loops, 'Expected #local.loops# lines. #local.lines# found');
-
- return;
- }
-}
View
18 model/content/ContentGateway.cfc
@@ -68,8 +68,8 @@
</cffunction>
<cffunction name="getChildren" output="false" returntype="query" hint="I return a query of child pages based upon the left and right value arguments">
- <cfargument name="left" required="false" hint="The left position">
- <cfargument name="right" required="false" hint="The right position">
+ <cfargument name="left" required="true" hint="The left position">
+ <cfargument name="right" required="true" hint="The right position">
<cfargument name="clearcache" required="false" default="false">
<cfset var qChildren = "">
<cfif arguments.clearcache>
@@ -238,4 +238,18 @@
return !ArrayLen( matches );
}
</cfscript>
+
+ <cffunction name="shiftPages" output="false" returntype="void">
+ <cfargument name="affectedpages" required="true" hint="The moved page's id">
+ <cfargument name="shift" required="true" hint="The number of positions to shift">
+
+ <cfquery>
+ update Pages set
+ page_left = page_left + #shift#,
+ page_right = page_right + #shift#
+ where page_id in (
+ <cfqueryparam value="#arguments.affectedpages#" cfsqltype="cf_sql_integer" list="true">
+ )
+ </cfquery>
+ </cffunction>
</cfcomponent>
View
41 model/content/ContentService.cfc
@@ -39,7 +39,7 @@ component accessors="true" extends="model.abstract.BaseService" {
*/
query function getChildren( Page, clearcache=false ){
return variables.ContentGateway.getChildren( left=arguments.Page.getLeftValue(), right=arguments.Page.getRightValue(), clearcache=arguments.clearcache );
- }
+ }
/**
* I return a page matching an id
@@ -117,15 +117,42 @@ component accessors="true" extends="model.abstract.BaseService" {
// accepts an array of structs
// TODO: doesn't currently update left and right values of sub pages - need to fix
boolean function saveSortOrder( required array pages ) {
+ var newLeft = -1;
+ var width = -1;
+ var newRight = -1;
+ var affectedpages = -1;
+ var sorted = [];
+ for ( var page in arguments.pages ){
+ var PageEntity = getPage( page.pageid );
+ if ( IsNull( PageEntity ) || !PageEntity.isPersisted() ) return false;
+ width = PageEntity.getrightvalue() - PageEntity.getleftvalue();
+ if ( newLeft == -1 ) newLeft = page.left; // first time thorough the loop
+ else newLeft = newRight + 1;
+ newRight = newLeft + width;
+ shift = newLeft - PageEntity.getleftvalue();
+ affectedpages = PageEntity.getPageID();
+ if ( shift != 0 ){
+ var qDescendants = variables.ContentGateway.getNavigation( left=PageEntity.getleftvalue(), right=PageEntity.getrightvalue() );
+ if ( qDescendants.recordCount ) affectedpages &= "," & ValueList( qDescendants.pageid );
+ }
+ // storing extra info to help debug
+ ArrayAppend( sorted, {
+ shift=shift,
+ affectedpages=affectedpages,
+ newLeft=newLeft,
+ newRight=newRight,
+ width=width,
+ title=PageEntity.getTitle()
+ } );
+ }
+ // now it's all figured out, save it
transaction{
- for ( var page in arguments.pages ){
- var PageEntity = getPage( page.pageid );
- if ( IsNull( PageEntity ) || !PageEntity.isPersisted() ) return false;
- PageEntity.setleftvalue( page.left );
- PageEntity.setrightvalue( page.right );
- variables.ContentGateway.savePage( PageEntity, 0 );
+ for ( var node in sorted ) {
+ if ( node.shift != 0 ) variables.ContentGateway.shiftPages( affectedpages=node.affectedpages, shift=node.shift );
}
}
+ // as we've used SQL instead of ORM to adjust clear ORM cache
+ ORMEvictEntity( "Page" );
return true;
}
View
2 model/user/User.xml.cfm
@@ -18,7 +18,7 @@
</rule>
</property>
<property name="username" desc="username">
- <rule type="required" contexts="create,update,login,password" />
+ <rule type="required" contexts="create,update,login" />
<rule type="custom" contexts="create,update" failureMessage="The username is registered to an existing account.">
<param name="methodname" value="isUsernameUnique" />
</rule>
View
6 public/layouts/default.cfm
@@ -21,9 +21,9 @@
<link rel="shortcut icon" href="favicon.ico">
- <link rel="apple-touch-icon-precomposed" sizes="114x114" href="public/assets/ico/apple-touch-icon-114-precomposed.png">
- <link rel="apple-touch-icon-precomposed" sizes="72x72" href="public/assets/ico/apple-touch-icon-72-precomposed.png">
- <link rel="apple-touch-icon-precomposed" href="public/assets/ico/apple-touch-icon-57-precomposed.png">
+ <link rel="apple-touch-icon-precomposed" sizes="114x114" href="apple-touch-icon-114-precomposed.png">
+ <link rel="apple-touch-icon-precomposed" sizes="72x72" href="apple-touch-icon-72-precomposed.png">
+ <link rel="apple-touch-icon-precomposed" href="apple-touch-icon-57-precomposed.png">
<cfif rc.config.news.enabled><link rel="alternate" type="application/rss+xml" href="#buildURL( 'news.rss' )#"></cfif>
</head>

0 comments on commit cd702f6

Please sign in to comment.
Something went wrong with that request. Please try again.