Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
1. New version of release database.
2. Content id not being set correctly, now fetch content type by content
id.
  • Loading branch information
deanblackborough committed Mar 18, 2015
1 parent 4c45b64 commit f67794d
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,8 @@ public function autoToolAction()
break;

case 'content_id':
$this->session_content->setContentId($id['id'], 'heading');
$this->session_content->setContentId($id['id'],
$id['content_type']);
break;

default:
Expand Down
32 changes: 32 additions & 0 deletions library/Dlayer/Model/Page/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -841,4 +841,36 @@ public function contentRowDivId($site_id, $page_id, $content_row_id)
return FALSE;
}
}

/**
* Fetch the content type by the content id
*
* @param integer $site_id
* @param integer $page_id
* @param integer $content_id
* @return string|FALSE Content type for given content id
*/
public function contentTypeByContentId($site_id, $page_id, $content_id)
{
$sql = 'SELECT dct.`name`
FROM user_site_page_content_item uspci
JOIN designer_content_type dct
ON uspci.content_type = dct.id
WHERE uspci.site_id = :site_id
AND uspci.page_id = :page_id
AND uspci.id = :content_id';
$stmt = $this->_db->prepare($sql);
$stmt->bindValue(':site_id', $site_id, PDO::PARAM_INT);
$stmt->bindValue(':page_id', $page_id, PDO::PARAM_INT);
$stmt->bindValue(':content_id', $content_id, PDO::PARAM_INT);
$stmt->execute();

$result = $stmt->fetch();

if($result != FALSE) {
return $result['name'];
} else {
return FALSE;
}
}
}
11 changes: 8 additions & 3 deletions library/Dlayer/Tool/Content/MoveItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,11 +114,15 @@ protected function structure($site_id, $page_id, $div_id,
$this->params_auto['content_row_id'],
$this->params_auto['content_id']);

$content_type = $model_page_content->contentTypeByContentId($site_id,
$page_id, $this->params_auto['content_id']);

/**
* Only return the array to set environment properties if the div id
* can be selected for the content row
* can be selected for the new content row and the content type is
* returned for the content id
*/
if($new_div_id != FALSE) {
if($new_div_id != FALSE && $content_type != FALSE) {
return array(
array(
'type'=>'div_id',
Expand All @@ -130,7 +134,8 @@ protected function structure($site_id, $page_id, $div_id,
),
array(
'type'=>'content_id',
'id'=>$this->params_auto['content_id']
'id'=>$this->params_auto['content_id'],
'content_type'=>$content_type
),
);
} else {
Expand Down
6 changes: 3 additions & 3 deletions private/database/release-database.sql

Large diffs are not rendered by default.

0 comments on commit f67794d

Please sign in to comment.