Version 4.1.19
This commit is contained in:
1 parent
28bd025b35
commit
2bd5025018
2674 files changed
+233518
-77766
No files matched your search
@@ -2,9 +2,10 @@
|
||||
/**
|
||||
* @brief Folder Model
|
||||
* @author <a href='http://www.invisionpower.com'>Invision Power Services, Inc.</a>
|
||||
* @copyright (c) 2001 - SVN_YYYY Invision Power Services, Inc.
|
||||
* @copyright (c) 2001 - 2016 Invision Power Services, Inc.
|
||||
* @license http://www.invisionpower.com/legal/standards/
|
||||
* @package IPS Social Suite
|
||||
* @package IPS Community Suite
|
||||
* @subpackage Content
|
||||
* @since 15 Jan 2014
|
||||
* @version SVN_VERSION_NUMBER
|
||||
*/
|
||||
@@ -72,6 +73,11 @@ class _Folder extends \IPS\Node\Model
|
||||
*/
|
||||
protected static $databaseIdFields = array('folder_name', 'folder_path');
|
||||
|
||||
/**
|
||||
* @brief [ActiveRecord] Multiton Map
|
||||
*/
|
||||
protected static $multitonMap = array();
|
||||
|
||||
/**
|
||||
* @brief [Node] Parent ID Database Column
|
||||
*/
|
||||
@@ -120,6 +126,16 @@ class _Folder extends \IPS\Node\Model
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Node titles can contain HTML. Apparently.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get__stripTagsTitle()
|
||||
{
|
||||
return $this->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get sortable name
|
||||
*
|
||||
@@ -181,7 +197,20 @@ class _Folder extends \IPS\Node\Model
|
||||
|
||||
if ( isset( $buttons['delete'] ) )
|
||||
{
|
||||
$return['delete'] = $buttons['delete'];
|
||||
if ( $this->getItemCount() )
|
||||
{
|
||||
$return['delete'] = array(
|
||||
'icon' => 'trash-o',
|
||||
'title' => 'empty',
|
||||
'link' => $url->setQueryString( array( 'do' => 'delete', 'id' => $this->_id, 'deleteNode' => 0 ) ),
|
||||
'data' => array( 'ipsDialog' => '', 'ipsDialog-title' => \IPS\Member::loggedIn()->language()->addToStack('empty') ),
|
||||
'hotkey'=> 'd'
|
||||
);
|
||||
}
|
||||
else
|
||||
{
|
||||
$return['delete'] = $buttons['delete'];
|
||||
}
|
||||
}
|
||||
|
||||
return $return;
|
||||
@@ -200,7 +229,23 @@ class _Folder extends \IPS\Node\Model
|
||||
{
|
||||
try
|
||||
{
|
||||
$test = \IPS\cms\Pages\Folder::load( \IPS\Http\Url::seoTitle( $val ), 'folder_name' );
|
||||
$testPage = \IPS\cms\Pages\Page::load( $val, 'page_seo_name' );
|
||||
|
||||
/* Ok, we have a folder, but is it on the same tree as us ?*/
|
||||
if ( intval( \IPS\Request::i()->folder_parent_id ) == $testPage->folder_id )
|
||||
{
|
||||
/* Yep, this will break designers' mode and may confuse the FURL engine so we cannot allow this */
|
||||
throw new \InvalidArgumentException('content_folder_name_furl_collision_folder');
|
||||
}
|
||||
}
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
/* Nothing with the same name, so that's proper good that is */
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
$test = \IPS\cms\Pages\Folder::load( \IPS\Http\Url\Friendly::seoTitle( $val ), 'folder_name' );
|
||||
|
||||
if ( ! empty( \IPS\Request::i()->id ) and $test->id != \IPS\Request::i()->id )
|
||||
{
|
||||
@@ -210,7 +255,7 @@ class _Folder extends \IPS\Node\Model
|
||||
catch ( \OutOfRangeException $e )
|
||||
{
|
||||
/* If we hit here, we don't have an existing folder by that name so check for a collision */
|
||||
if ( \IPS\Request::i()->folder_parent_id == 0 AND \IPS\cms\Pages\Page::isFurlCollision( \IPS\Http\Url::seoTitle( $val ) ) )
|
||||
if ( \IPS\Request::i()->folder_parent_id == 0 AND \IPS\cms\Pages\Page::isFurlCollision( \IPS\Http\Url\Friendly::seoTitle( $val ) ) )
|
||||
{
|
||||
throw new \InvalidArgumentException('content_folder_name_furl_collision');
|
||||
}
|
||||
@@ -260,7 +305,7 @@ class _Folder extends \IPS\Node\Model
|
||||
|
||||
if( isset( $values['folder_name'] ) )
|
||||
{
|
||||
$values['name'] = \IPS\Http\Url::seoTitle( $values['folder_name'] );
|
||||
$values['name'] = \IPS\Http\Url\Friendly::seoTitle( $values['folder_name'] );
|
||||
unset( $values['folder_name'] );
|
||||
}
|
||||
|
||||
@@ -322,6 +367,65 @@ class _Folder extends \IPS\Node\Model
|
||||
parent::save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve item count (if applicable) for a node.
|
||||
*
|
||||
* @return int|bool
|
||||
*/
|
||||
public function getItemCount()
|
||||
{
|
||||
return (int) \IPS\Db::i()->select( 'COUNT(*)', 'cms_pages', array( 'page_folder_id=?', $this->id ) )->first();
|
||||
}
|
||||
|
||||
/**
|
||||
* Form to delete or move content
|
||||
*
|
||||
* @param bool $showMoveToChildren If TRUE, will show "move to children" even if there are no children
|
||||
* @return \IPS\Helpers\Form
|
||||
*/
|
||||
public function deleteOrMoveForm( $showMoveToChildren=FALSE )
|
||||
{
|
||||
$hasContent = $this->getItemCount();
|
||||
|
||||
$form = new \IPS\Helpers\Form( 'form', 'delete' );
|
||||
|
||||
if ( $hasContent )
|
||||
{
|
||||
$form->add( new \IPS\Helpers\Form\Node( 'cms_move_pages', 0, TRUE, array( 'class' => get_class( $this ), 'disabled' => array( $this->_id ), 'disabledLang' => 'node_move_delete', 'zeroVal' => 'cms_move_to_root', 'subnodes' => FALSE, 'permissionCheck' => function( $node )
|
||||
{
|
||||
return \IPS\Request::i()->id != $node->id;
|
||||
} ) ) );
|
||||
}
|
||||
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle submissions of form to delete or move content
|
||||
*
|
||||
* @param array $values Values from form
|
||||
* @param bool $deleteWhenDone Delete the node when done?
|
||||
* @return void
|
||||
*/
|
||||
public function deleteOrMoveFormSubmit( $values, $deleteWhenDone=TRUE )
|
||||
{
|
||||
if ( $values['cms_move_pages'] )
|
||||
{
|
||||
$folderId = $values['cms_move_pages']->id;
|
||||
}
|
||||
else
|
||||
{
|
||||
$folderId = 0;
|
||||
}
|
||||
|
||||
\IPS\Db::i()->update( 'cms_pages', array( 'page_folder_id' => $folderId ), array( 'page_folder_id=?', $this->id ) );
|
||||
\IPS\Db::i()->update( 'cms_folders', array( 'folder_parent_id' => $folderId ), array( 'folder_id=?', $this->id ) );
|
||||
|
||||
/* Delete it */
|
||||
\IPS\Session::i()->log( 'acplog__node_deleted', array( $this->title => TRUE, $this->titleForLog() => FALSE ) );
|
||||
$this->delete();
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the stored path
|
||||
*
|
||||
|
||||
Reference in new issue
Block a user