Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update for Symphony 4.x #31

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 66 additions & 31 deletions assets/publish_tabs.publish.css
Original file line number Diff line number Diff line change
@@ -1,42 +1,77 @@
.tab-group {
/*-----------------------------------------------------------------------------
Tabs
-----------------------------------------------------------------------------*/

#context > .tabs {
order: 2;
box-sizing: border-box;
display: flex;
flex-direction: row;
align-items: center;
justify-content: flex-start;
position: absolute;
top: -99999em;
left: -99999em;
width: 100%;
left: 0;
right: 0;
top: 100%;
margin: 1px 0 0;
padding: 0 3rem;
border-bottom: 1px solid #d3dce2;
background: #fff;
height: 6rem;
z-index: 10;
white-space: nowrap;
list-style-type: none;
}

#context > .tabs li {
box-sizing: border-box;
position: relative;
color: #3B3D40;
font-size: 1.2rem;
text-transform: uppercase;
line-height: 6rem;
margin-right: 3rem;
margin-bottom: -1px;
border-bottom: 2px solid transparent;
height: 6rem;
cursor: pointer;
}

#context > .tabs li + li {
margin-left: 1rem;
}

.tab-group-selected {
position: static;
#context > .tabs li:hover,
#context > .tabs li.selected,
#context > .tabs li.active {
color: #2f77eb!important;
border-bottom-color: #2f77eb;
z-index: 10;
}

ul.tabs li.invalid .icon {
background: #f4f4f4;
color: rgba(255, 255, 255, 0.7);
-webkit-box-shadow: none;
box-shadow: none;
display: inline-block;
vertical-align: top;
text-align: center;
width: 16px;
height: 16px;
line-height: 16px;
margin: 0 0 0 5px;
border-radius: 8px;
font-weight: lighter;
#context > .tabs li.invalid {
color: #ee494e!important;
}

ul.tabs li.invalid.selected .icon {
background: #dd4422;
color: #f4f4f4;
#context > .tabs li.invalid:hover,
#context > .tabs li.invalid.selected,
#context > .tabs li.invalid.selected:hover {
color: #ee494e!important;
border-bottom-color: #ee494e;
z-index: 10;
}

ul.tabs li.invalid:hover,
ul.tabs li.invalid .icon {
text-shadow: none;
color: #dd4422;
/*-----------------------------------------------------------------------------
Tab Groups
-----------------------------------------------------------------------------*/

body.publish-tabs #contents {
padding-top: 12rem;
}

ul.tabs li.invalid:hover .icon {
background: #dd4422;
color: rgba(255, 255, 255, 0.7);
}
.tab-group:not(.tab-group-selected) {
position: absolute;
top: -99999em;
left: -99999em;
width: 100%;
}
31 changes: 22 additions & 9 deletions extension.driver.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,31 @@
class extension_publish_tabs extends Extension {

public function uninstall() {
Symphony::Database()->query("DROP TABLE `tbl_fields_publish_tabs`");
return Symphony::Database()
->drop('tbl_fields_publish_tabs')
->ifExists()
->execute()
->success();
}

public function install() {
Symphony::Database()->query(
"CREATE TABLE IF NOT EXISTS `tbl_fields_publish_tabs` (
`id` int(11) NOT NULL auto_increment,
`field_id` int(11) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
return true;
return Symphony::Database()
->create('tbl_fields_publish_tabs')
->ifNotExists()
->charset('utf8')
->collate('utf8_unicode_ci')
->fields([
'id' => [
'type' => 'int(11)',
'auto' => true,
],
'field_id' => 'int(11)',
])
->keys([
'id' => 'primary',
])
->execute()
->success();
}

public function getSubscribedDelegates() {
Expand Down
4 changes: 4 additions & 0 deletions extension.meta.xml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@
<item type="image" url="http://symphonyextensions.com/nickdunn/publish_tabs/media/publish_tabs.png">Publish Tabs: Add tab groups to entry create/edit forms</item>
</media>
<releases>
<release version="2.0.0" date="TBA" min="4.0.0" max="4.x.x" php-min="5.6.x" php-max="7.x.x">
- Update for Symphony 4.x
- Code refactoring for Database and EQFA
</release>
<release version="1.3.1" date="2015-02-02" min="2.4" max="2.6.x">
- Marked as compatible with Symphony 2.6.x
- Removed the field from the Data Source editor since it outputs nothing.
Expand Down
59 changes: 40 additions & 19 deletions fields/field.publish_tabs.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,16 +20,29 @@ public function __construct(){
-------------------------------------------------------------------------*/

public function createTable(){
return Symphony::Database()->query(
"CREATE TABLE IF NOT EXISTS `tbl_entries_data_" . $this->get('id') . "` (
`id` int(11) unsigned NOT NULL auto_increment,
`entry_id` int(11) unsigned NOT NULL,
`value` double default NULL,
PRIMARY KEY (`id`),
KEY `entry_id` (`entry_id`),
KEY `value` (`value`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
);
return Symphony::Database()
->create('tbl_entries_data_' . $this->get('id'))
->ifNotExists()
->charset('utf8')
->collate('utf8_unicode_ci')
->fields([
'id' => [
'type' => 'int(11)',
'auto' => true,
],
'entry_id' => 'int(11)',
'value' => [
'type' => 'double',
'null' => true,
],
])
->keys([
'id' => 'primary',
'entry_id' => 'key',
'value' => 'key',
])
->execute()
->success();
}

/*-------------------------------------------------------------------------
Expand All @@ -53,11 +66,11 @@ public function commit(){
Publish:
-------------------------------------------------------------------------*/

public function displayPublishPanel(XMLElement &$wrapper, $data = NULL, $flagWithError = NULL, $fieldnamePrefix = NULL, $fieldnamePostfix = NULL, $entry_id = NULL){
public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null){
$wrapper->setValue($this->get('label'));
}

public function processRawFieldData($data, &$status, &$message = NULL, $simulate = false, $entry_id = NULL) {
public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null) {
$status = self::__OK__;

return array(
Expand All @@ -73,26 +86,34 @@ public function fetchIncludableElements() {
return null;
}

public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = NULL, $entry_id = NULL) {
public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null) {

}

public function prepareReadableValue($data, $entry_id = NULL, $truncate = false, $defaultValue = NULL) {
public function prepareReadableValue($data, $entry_id = null, $truncate = false, $defaultValue = null) {
return $this->prepareTableValue($data, null, $entry_id);
}

public function prepareTableValue($data, XMLElement $link=NULL, $entry_id=NULL) {
public function prepareTableValue($data, XMLElement $link = null, $entry_id = null) {
// build this entry fully
$entries = EntryManager::fetch($entry_id);

if ($entries === false) return parent::prepareTableValue(NULL, $link, $entry_id);
if ($entries === false) return parent::prepareTableValue(null, $link, $entry_id);

$entry = reset(EntryManager::fetch($entry_id));

// get the first field inside this tab
$field_id = Symphony::Database()->fetchVar('id', 0, "SELECT `id` FROM `tbl_fields` WHERE `parent_section` = '".$this->get('parent_section')."' AND `sortorder` = ".($this->get('sortorder') + 1)." ORDER BY `sortorder` LIMIT 1");

if ($field_id === NULL) return parent::prepareTableValue(NULL, $link, $entry_id);
$field_id = Symphony::Database()
->select(['id'])
->from('tbl_fields')
->where(['parent_section' => $this->get('parent_section')])
->where(['sortorder' => ($this->get('sortorder') + 1)])
->orderBy('sortorder')
->limit(1)
->execute()
->variable('id');

if ($field_id === null) return parent::prepareTableValue(null, $link, $entry_id);

$field = FieldManager::fetch($field_id);

Expand Down