diff --git a/_bootstrap/index.php b/_bootstrap/index.php old mode 100644 new mode 100755 index 7593740..414421e --- a/_bootstrap/index.php +++ b/_bootstrap/index.php @@ -135,6 +135,10 @@ $manager->createObjectContainer($oC); } +$manager->alterField('qsbButton', 'icon'); +$manager->addField('qsbButton', 'icon_ms', array('after' => 'icon')); +$manager->addField('qsbButton', 'icon_file', array('after' => 'icon_ms')); + if (isset($_GET['loadIcons'])) { echo "Loading icons..\n"; diff --git a/_build/build.schema.php b/_build/build.schema.php index b7be81d..3554c48 100755 --- a/_build/build.schema.php +++ b/_build/build.schema.php @@ -3,7 +3,7 @@ define('PKG_NAME', 'QuickstartButtons'); define('PKG_NAME_LOWER', strtolower(PKG_NAME)); -require_once dirname(__FILE__).'/build.config.php'; +require_once dirname(dirname(__FILE__)) . '/config.core.php'; include_once MODX_CORE_PATH . 'model/modx/modx.class.php'; $modx = new modX(); diff --git a/_build/resolvers/resolve.dbchanges.php b/_build/resolvers/resolve.dbchanges.php index 9d6ef49..49bff1e 100755 --- a/_build/resolvers/resolve.dbchanges.php +++ b/_build/resolvers/resolve.dbchanges.php @@ -1,5 +1,6 @@ xpdo; switch($options[xPDOTransport::PACKAGE_ACTION]) { @@ -16,7 +17,13 @@ $oldLogLevel = $modx->getLogLevel(); $modx->setLogLevel(0); - $manager->addField('qsbButton', 'action_props', array('after' => 'action_id')); // since 1.0.1 + // since 1.0.1 + $manager->addField('qsbButton', 'action_props', array('after' => 'action_id')); + + // since 1.1.0 + $manager->alterField('qsbButton', 'icon'); + $manager->addField('qsbButton', 'icon_ms', array('after' => 'icon')); + $manager->addField('qsbButton', 'icon_file', array('after' => 'icon_ms')); // set back console logging $modx->setLogLevel($oldLogLevel); diff --git a/assets/components/quickstartbuttons/css/mgr.css b/assets/components/quickstartbuttons/css/mgr.css index 1f72f5d..1dc93a1 100755 --- a/assets/components/quickstartbuttons/css/mgr.css +++ b/assets/components/quickstartbuttons/css/mgr.css @@ -145,7 +145,7 @@ i.icon { display: inline-block; width: 16px; height: 16px; - background-size: 31px; + background-size: 100%; background-repeat: no-repeat; background-position: left center; } diff --git a/assets/components/quickstartbuttons/js/mgr/widgets/buttons.grid.js b/assets/components/quickstartbuttons/js/mgr/widgets/buttons.grid.js index e789bab..d7a9ccb 100755 --- a/assets/components/quickstartbuttons/js/mgr/widgets/buttons.grid.js +++ b/assets/components/quickstartbuttons/js/mgr/widgets/buttons.grid.js @@ -8,7 +8,7 @@ QuickstartButtons.grid.Buttons = function(config) { ,save_action: 'mgr/buttons/updateFromGrid' ,autosave: true - ,fields: ['id','set','icon','iconcls','iconpath','text','description','ranking','action_id','action_props','handler','link','newwindow','active'] + ,fields: ['id','set','icon','icon_ms','icon_file','iconcls','iconpath','text','description','ranking','action_id','action_props','handler','link','newwindow','active'] ,paging: true ,pageSize: 6 ,remoteSort: true @@ -119,11 +119,10 @@ Ext.extend(QuickstartButtons.grid.Buttons, MODx.grid.Grid, { var r = s.getAt(ri).data; if(!Ext.isEmpty(r.iconpath)) { - return ' ' + v; + return ' ' + v; } - var iconCls = (!Ext.isEmpty(r.iconcls) ? r.iconcls : 'fa-chevron-right'); - return ' ' + v; + return ' ' + v; } ,renderYNfield: function(v,md,rec,ri,ci,s,g) { var r = s.getAt(ri).data; diff --git a/assets/components/quickstartbuttons/js/mgr/widgets/buttons.windows.js b/assets/components/quickstartbuttons/js/mgr/widgets/buttons.windows.js index f82913d..984773e 100755 --- a/assets/components/quickstartbuttons/js/mgr/widgets/buttons.windows.js +++ b/assets/components/quickstartbuttons/js/mgr/widgets/buttons.windows.js @@ -3,15 +3,15 @@ QuickstartButtons.window.CreateUpdateButton = function(config) { config = config || {}; this.ident = config.ident || Ext.id(); - +console.log(config); Ext.applyIf(config,{ - title: _('quickstartbuttons.sets.update') + title: _('quickstartbuttons.buttons.create') ,cls: 'quickstartbuttons-window-vtabs' ,bodyCssClass: 'window-vtabs' ,url: QuickstartButtons.config.connector_url ,baseParams: { action: ((config.isUpdate) ? 'mgr/buttons/update' : 'mgr/buttons/create') - ,set: config.setId || config.record.set + ,set: ((config.isUpdate) ? config.record.set : config.setId) } ,width: 650 ,resizable: false @@ -39,33 +39,11 @@ QuickstartButtons.window.CreateUpdateButton = function(config) { title: _('quickstartbuttons.general') ,layout: 'form' ,items: [{ - layout: 'column' - ,border: false - ,defaults: { msgTarget: 'under' ,border: false } - ,items: [{ - layout: 'form' - ,columnWidth: .5 - ,defaults: { msgTarget: 'under' ,border: false } - ,items: [{ - xtype: 'textfield' - ,fieldLabel: _('quickstartbuttons.buttons.text') - ,name: 'text' - ,anchor: '100%' - ,allowBlank: false - }] - },{ - layout: 'form' - ,columnWidth: .5 - ,defaults: { msgTarget: 'under' ,border: false } - ,items: [{ - xtype: 'quickstartbuttons-combo-icons' - ,fieldLabel: _('quickstartbuttons.buttons.icon') - ,name: 'icon' - ,anchor: '100%' - ,allowBlank: false - ,selected: config.record.icon - }] - }] + xtype: 'textfield' + ,fieldLabel: _('quickstartbuttons.buttons.text') + ,name: 'text' + ,anchor: '100%' + ,allowBlank: false },{ xtype: 'textarea' ,fieldLabel: _('quickstartbuttons.buttons.description') @@ -100,6 +78,59 @@ QuickstartButtons.window.CreateUpdateButton = function(config) { }] }] }] + },{ + title: _('quickstartbuttons.buttons.icon') + ,layout: 'form' + ,items: [/*{ + html: '

' + _('quickstartbuttons.buttons.icon_desc') + '


' + ,border: false + },*/{ + xtype: 'quickstartbuttons-combo-icons' + ,name: 'icon' + ,fieldLabel: _('quickstartbuttons.buttons.icon.preset') + ,anchor: '100%' + ,allowBlank: true + ,selected: config.record.icon + },{ + html: '
' + ,border: false + },{ + html: '----- ' + _('quickstartbuttons.buttons.icon.or') + ' -----' + ,border: false + ,bodyStyle: 'text-align:center;' + },{ + html: '
' + ,border: false + },{ + xtype: 'modx-combo-source' + ,id: 'quickstartbuttons-button-icon-ms-'+this.ident + ,name: 'icon_ms' + ,hiddenName: 'icon_ms' + ,fieldLabel: _('quickstartbuttons.buttons.icon.ms') + ,anchor: '100%' + ,allowBlank: true + ,listeners: { + 'select': { fn: function(cb,rec,idx) { + var fileFld = Ext.getCmp('quickstartbuttons-button-icon-msbrowse-'+this.ident); + fileFld.config.source = rec.id; + fileFld.browser = null; // to make the browser load again + fileFld.setValue(''); + fileFld.setDisabled(false); + } ,scope: this } + ,scope: this + } + },{ + xtype: 'modx-combo-browser' + ,id: 'quickstartbuttons-button-icon-msbrowse-'+this.ident + ,name: 'icon_file' + ,hiddenName: 'icon_file' + ,fieldLabel: _('quickstartbuttons.buttons.icon.select') + ,anchor: '100%' + ,allowBlank: true + ,disabled: ((config.isUpdate && !Ext.isEmpty(config.record.icon_ms)) ? false : true) + ,hideSourceCombo: true + ,allowedFileTypes: 'png,jpg,jpeg,gif,bmp,tiff' + }] },{ title: _('quickstartbuttons.buttons.link') ,layout: 'form' diff --git a/core/components/quickstartbuttons/elements/chunks/dashboard/item.chunk.tpl b/core/components/quickstartbuttons/elements/chunks/dashboard/item.chunk.tpl index 603584f..4a37f04 100755 --- a/core/components/quickstartbuttons/elements/chunks/dashboard/item.chunk.tpl +++ b/core/components/quickstartbuttons/elements/chunks/dashboard/item.chunk.tpl @@ -1,7 +1,7 @@
  • - + [[+text]]
    [[+description]] diff --git a/core/components/quickstartbuttons/lexicon/en/default.inc.php b/core/components/quickstartbuttons/lexicon/en/default.inc.php index adaa519..651a6e6 100755 --- a/core/components/quickstartbuttons/lexicon/en/default.inc.php +++ b/core/components/quickstartbuttons/lexicon/en/default.inc.php @@ -33,12 +33,17 @@ $_lang['quickstartbuttons.buttons_desc'] = "Below you will find the buttons configured in this set."; $_lang['quickstartbuttons.buttons.create'] = "Add new button"; -$_lang['quickstartbuttons.buttons.icon'] = "Button Icon"; $_lang['quickstartbuttons.buttons.text'] = "Button Text"; $_lang['quickstartbuttons.buttons.description'] = "Description"; $_lang['quickstartbuttons.buttons.ranking'] = "Ranking"; $_lang['quickstartbuttons.buttons.active'] = "Active"; +$_lang['quickstartbuttons.buttons.icon'] = "Icon"; +$_lang['quickstartbuttons.buttons.icon.preset'] = "Search & choose a preset icon"; +$_lang['quickstartbuttons.buttons.icon.or'] = "Or select a custom icon below"; +$_lang['quickstartbuttons.buttons.icon.ms'] = "The Media Source to search icons for"; +$_lang['quickstartbuttons.buttons.icon.select'] = "Select an icon from Media Source"; + $_lang['quickstartbuttons.buttons.link'] = "Link"; $_lang['quickstartbuttons.buttons.link_desc'] = "Below you can configure the action for the button. The priority of the link to use is from top down. This means that if you set the first, the second and third will be ignored and if you leave the first empty, set the second, the third one will be ignored etc."; $_lang['quickstartbuttons.buttons.link.action'] = "Systems Action"; diff --git a/core/components/quickstartbuttons/model/quickstartbuttons/dashboardwidget.class.php b/core/components/quickstartbuttons/model/quickstartbuttons/dashboardwidget.class.php index d37faf2..1907ee3 100755 --- a/core/components/quickstartbuttons/model/quickstartbuttons/dashboardwidget.class.php +++ b/core/components/quickstartbuttons/model/quickstartbuttons/dashboardwidget.class.php @@ -63,6 +63,7 @@ public function getDashboardButtons() { $idx = 1; foreach($buttons as $button) { + /** @var qsbButton $button */ $phs = $button->toArray(); $phs['idx'] = $idx; $phs['href'] = ''; diff --git a/core/components/quickstartbuttons/model/quickstartbuttons/mysql/qsbbutton.map.inc.php b/core/components/quickstartbuttons/model/quickstartbuttons/mysql/qsbbutton.map.inc.php index daa4057..1b9c7b9 100644 --- a/core/components/quickstartbuttons/model/quickstartbuttons/mysql/qsbbutton.map.inc.php +++ b/core/components/quickstartbuttons/model/quickstartbuttons/mysql/qsbbutton.map.inc.php @@ -6,8 +6,10 @@ 'extends' => 'xPDOSimpleObject', 'fields' => array ( - 'set' => 0, + 'set' => NULL, 'icon' => 0, + 'icon_ms' => 0, + 'icon_file' => NULL, 'text' => NULL, 'description' => '', 'action_id' => 0, @@ -26,7 +28,6 @@ 'precision' => '11', 'phptype' => 'integer', 'null' => false, - 'default' => 0, 'index' => 'index', ), 'icon' => @@ -34,10 +35,27 @@ 'dbtype' => 'int', 'precision' => '11', 'phptype' => 'integer', - 'null' => false, + 'null' => true, + 'default' => 0, + 'index' => 'index', + ), + 'icon_ms' => + array ( + 'dbtype' => 'int', + 'precision' => '11', + 'phptype' => 'integer', + 'null' => true, 'default' => 0, 'index' => 'index', ), + 'icon_file' => + array ( + 'dbtype' => 'varchar', + 'precision' => '255', + 'phptype' => 'string', + 'null' => true, + 'default' => NULL, + ), 'text' => array ( 'dbtype' => 'varchar', @@ -135,5 +153,13 @@ 'cardinality' => 'one', 'owner' => 'foreign', ), + 'MediaSource' => + array ( + 'class' => 'modMediaSource', + 'local' => 'icon_ms', + 'foreign' => 'id', + 'cardinality' => 'one', + 'owner' => 'foreign', + ), ), ); diff --git a/core/components/quickstartbuttons/model/quickstartbuttons/qsbbutton.class.php b/core/components/quickstartbuttons/model/quickstartbuttons/qsbbutton.class.php old mode 100644 new mode 100755 index 6a676a3..71c7d04 --- a/core/components/quickstartbuttons/model/quickstartbuttons/qsbbutton.class.php +++ b/core/components/quickstartbuttons/model/quickstartbuttons/qsbbutton.class.php @@ -1,2 +1,65 @@ getIcon(); + if(!empty($icon) && is_array($icon)) { + switch($icon['type']) { + case 'custom': + $arr['iconcls'] = ''; + $arr['iconpath'] = $icon['value']; + break; + case 'preset': + default: + $arr['iconcls'] = $icon['value']; + $arr['iconpath'] = ''; + break; + } + } + + return $arr; + } + + /** + * Figures out the icon to use + * @return array + */ + public function getIcon() { + + $icon_ms = $this->get('icon_ms'); + $icon_file = $this->get('icon_file'); + if(!empty($icon_ms) && !empty($icon_file)) { + + /** @var modMediaSource|modFileMediaSource $ms */ + $ms = $this->getOne('MediaSource'); + if(!empty($ms) && is_object($ms)) { + $ms->initialize(); + + $iconUrl = $ms->getObjectUrl($icon_file); + if(!empty($iconUrl)) { + return array('type' => 'custom', 'value' => $iconUrl); + } + } + } + + /** @var qsbIcon $icon - Fallback */ + $icon = $this->getOne('Icon'); + if(!empty($icon) && is_object($icon)) { + return array('type' => 'preset', 'value' => $icon->get('class')); + } + + return array('type' => 'preset', 'value' => 'fa-chevron-right'); + } +} \ No newline at end of file diff --git a/core/components/quickstartbuttons/model/schema/quickstartbuttons.mysql.schema.xml b/core/components/quickstartbuttons/model/schema/quickstartbuttons.mysql.schema.xml index 762336e..ff04567 100755 --- a/core/components/quickstartbuttons/model/schema/quickstartbuttons.mysql.schema.xml +++ b/core/components/quickstartbuttons/model/schema/quickstartbuttons.mysql.schema.xml @@ -26,8 +26,10 @@ - - + + + + @@ -43,6 +45,7 @@ + diff --git a/core/components/quickstartbuttons/processors/mgr/buttons/create.class.php b/core/components/quickstartbuttons/processors/mgr/buttons/create.class.php index dadf361..455426c 100755 --- a/core/components/quickstartbuttons/processors/mgr/buttons/create.class.php +++ b/core/components/quickstartbuttons/processors/mgr/buttons/create.class.php @@ -7,6 +7,8 @@ class QuickstartButtonsCreateProcessor extends modObjectCreateProcessor { public function beforeSet() { + // link + $action = $this->getProperty('action_id'); if(empty($action)) { $this->setProperty('action_id', null); } else { $this->setProperty('action', $action); } @@ -17,6 +19,17 @@ public function beforeSet() { $link = $this->getProperty('link'); if(empty($link)) { $this->setProperty('link', null); } + // icon + + $icon = $this->getProperty('icon'); + if(empty($icon)) { $this->setProperty('icon', null); } + + $iconms = $this->getProperty('icon_ms'); + if(empty($iconms)) { $this->setProperty('icon_ms', null); } + + $iconfile = $this->getProperty('icon_file'); + if(empty($iconfile)) { $this->setProperty('icon_file', null); } + return parent::beforeSet(); } diff --git a/core/components/quickstartbuttons/processors/mgr/buttons/getlist.class.php b/core/components/quickstartbuttons/processors/mgr/buttons/getlist.class.php index 28d53ac..babe3f7 100755 --- a/core/components/quickstartbuttons/processors/mgr/buttons/getlist.class.php +++ b/core/components/quickstartbuttons/processors/mgr/buttons/getlist.class.php @@ -7,11 +7,6 @@ class QuickstartButtonsGetListProcessor extends modObjectGetListProcessor { public $defaultSortDirection = 'ASC'; public $objectType = 'quickstartbuttons.qsbbutton'; - public function initialize() { - $this->modx->getParser(); - return parent::initialize(); - } - public function prepareQueryBeforeCount(xPDOQuery $c) { $c->select(array('qsbButton.*', 'Icon.class AS iconcls', 'Icon.path as iconpath')); @@ -28,16 +23,6 @@ public function prepareQueryBeforeCount(xPDOQuery $c) { return $c; } - - public function prepareRow(xPDOObject $object) { - $arr = $object->toArray(); - - $path = $object->get('iconpath'); - $this->modx->parser->processElementTags('', $path, true, true); - $arr['iconpath'] = $path; - - return $arr; - } } return 'QuickstartButtonsGetListProcessor'; diff --git a/core/components/quickstartbuttons/processors/mgr/buttons/update.class.php b/core/components/quickstartbuttons/processors/mgr/buttons/update.class.php index 2635677..293fa6c 100755 --- a/core/components/quickstartbuttons/processors/mgr/buttons/update.class.php +++ b/core/components/quickstartbuttons/processors/mgr/buttons/update.class.php @@ -7,6 +7,8 @@ class QuickstartButtonsUpdateProcessor extends modObjectUpdateProcessor { public function beforeSet() { + // link + $action = $this->getProperty('action_id'); if(empty($action)) { $this->setProperty('action_id', null); } else { $this->setProperty('action', $action); } @@ -17,6 +19,17 @@ public function beforeSet() { $link = $this->getProperty('link'); if(empty($link)) { $this->setProperty('link', null); } + // icon + + $icon = $this->getProperty('icon'); + if(empty($icon)) { $this->setProperty('icon', null); } + + $iconms = $this->getProperty('icon_ms'); + if(empty($iconms)) { $this->setProperty('icon_ms', null); } + + $iconfile = $this->getProperty('icon_file'); + if(empty($iconfile)) { $this->setProperty('icon_file', null); } + return parent::beforeSet(); }