summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.cvsignore3
-rw-r--r--CHANGELOG.txt30
-rw-r--r--LICENSE.txt274
-rw-r--r--delta.info2
-rw-r--r--delta.install37
-rw-r--r--delta.module168
-rw-r--r--delta_ui.admin.inc463
-rw-r--r--delta_ui.js3
-rw-r--r--delta_ui.module227
-rw-r--r--delta_ui/delta_ui.admin.inc188
-rw-r--r--delta_ui/delta_ui.info (renamed from delta_ui.info)4
-rw-r--r--delta_ui/delta_ui.module95
-rw-r--r--plugins/context_reaction_delta.inc54
13 files changed, 735 insertions, 813 deletions
diff --git a/.cvsignore b/.cvsignore
deleted file mode 100644
index 94bbfc6..0000000
--- a/.cvsignore
+++ /dev/null
@@ -1,3 +0,0 @@
-.gitignore
-.git
-SVN
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 06fe44f..812c050 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -21,32 +21,4 @@ Maintainer(s): Jake Strawn
http://twitter.com/himerus
##########################################################################################
##### CHANGELOG.txt
-##########################################################################################
-
-
-##########################################################################################
-##### Delta 7.x-2.0-ALPHA1
-##########################################################################################
-
-1/11/11
-=======
- Initial commit, and tag as 7.x-2.0-ALPHA1
-
- Version Tag: 7.x-2.0-ALPHA1
-
-##########################################################################################
-##### Delta 7.x-2.0-ALPHA2
-##########################################################################################
-
-1/12/11
-=======
- #1024052 by pivica - pass by reference warning
- --- Adding CHANGELOG.txt to repository
- #1024834 - fix typo in delta_ui.info for detla_ui.js
- #1024848 - Remove extra table from hook_schema
-
-1/14/11
-=======
- #1027120 by himerus - Rename Templates to Layouts
-
- Pending Version Tag: 7.x-2.0-ALPHA2 \ No newline at end of file
+########################################################################################## \ No newline at end of file
diff --git a/LICENSE.txt b/LICENSE.txt
new file mode 100644
index 0000000..2c095c8
--- /dev/null
+++ b/LICENSE.txt
@@ -0,0 +1,274 @@
+GNU GENERAL PUBLIC LICENSE
+
+ Version 2, June 1991
+
+Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave,
+Cambridge, MA 02139, USA. Everyone is permitted to copy and distribute
+verbatim copies of this license document, but changing it is not allowed.
+
+ Preamble
+
+The licenses for most software are designed to take away your freedom to
+share and change it. By contrast, the GNU General Public License is
+intended to guarantee your freedom to share and change free software--to
+make sure the software is free for all its users. This General Public License
+applies to most of the Free Software Foundation's software and to any other
+program whose authors commit to using it. (Some other Free Software
+Foundation software is covered by the GNU Library General Public License
+instead.) You can apply it to your programs, too.
+
+When we speak of free software, we are referring to freedom, not price. Our
+General Public Licenses are designed to make sure that you have the
+freedom to distribute copies of free software (and charge for this service if
+you wish), that you receive source code or can get it if you want it, that you
+can change the software or use pieces of it in new free programs; and that
+you know you can do these things.
+
+To protect your rights, we need to make restrictions that forbid anyone to
+deny you these rights or to ask you to surrender the rights. These restrictions
+translate to certain responsibilities for you if you distribute copies of the
+software, or if you modify it.
+
+For example, if you distribute copies of such a program, whether gratis or for
+a fee, you must give the recipients all the rights that you have. You must make
+sure that they, too, receive or can get the source code. And you must show
+them these terms so they know their rights.
+
+We protect your rights with two steps: (1) copyright the software, and (2)
+offer you this license which gives you legal permission to copy, distribute
+and/or modify the software.
+
+Also, for each author's protection and ours, we want to make certain that
+everyone understands that there is no warranty for this free software. If the
+software is modified by someone else and passed on, we want its recipients
+to know that what they have is not the original, so that any problems
+introduced by others will not reflect on the original authors' reputations.
+
+Finally, any free program is threatened constantly by software patents. We
+wish to avoid the danger that redistributors of a free program will individually
+obtain patent licenses, in effect making the program proprietary. To prevent
+this, we have made it clear that any patent must be licensed for everyone's
+free use or not licensed at all.
+
+The precise terms and conditions for copying, distribution and modification
+follow.
+
+ GNU GENERAL PUBLIC LICENSE
+ TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND
+ MODIFICATION
+
+0. This License applies to any program or other work which contains a notice
+placed by the copyright holder saying it may be distributed under the terms
+of this General Public License. The "Program", below, refers to any such
+program or work, and a "work based on the Program" means either the
+Program or any derivative work under copyright law: that is to say, a work
+containing the Program or a portion of it, either verbatim or with
+modifications and/or translated into another language. (Hereinafter, translation
+is included without limitation in the term "modification".) Each licensee is
+addressed as "you".
+
+Activities other than copying, distribution and modification are not covered
+by this License; they are outside its scope. The act of running the Program is
+not restricted, and the output from the Program is covered only if its contents
+constitute a work based on the Program (independent of having been made
+by running the Program). Whether that is true depends on what the Program
+does.
+
+1. You may copy and distribute verbatim copies of the Program's source
+code as you receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice and
+disclaimer of warranty; keep intact all the notices that refer to this License
+and to the absence of any warranty; and give any other recipients of the
+Program a copy of this License along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and you
+may at your option offer warranty protection in exchange for a fee.
+
+2. You may modify your copy or copies of the Program or any portion of it,
+thus forming a work based on the Program, and copy and distribute such
+modifications or work under the terms of Section 1 above, provided that you
+also meet all of these conditions:
+
+a) You must cause the modified files to carry prominent notices stating that
+you changed the files and the date of any change.
+
+b) You must cause any work that you distribute or publish, that in whole or in
+part contains or is derived from the Program or any part thereof, to be
+licensed as a whole at no charge to all third parties under the terms of this
+License.
+
+c) If the modified program normally reads commands interactively when run,
+you must cause it, when started running for such interactive use in the most
+ordinary way, to print or display an announcement including an appropriate
+copyright notice and a notice that there is no warranty (or else, saying that
+you provide a warranty) and that users may redistribute the program under
+these conditions, and telling the user how to view a copy of this License.
+(Exception: if the Program itself is interactive but does not normally print such
+an announcement, your work based on the Program is not required to print
+an announcement.)
+
+These requirements apply to the modified work as a whole. If identifiable
+sections of that work are not derived from the Program, and can be
+reasonably considered independent and separate works in themselves, then
+this License, and its terms, do not apply to those sections when you distribute
+them as separate works. But when you distribute the same sections as part
+of a whole which is a work based on the Program, the distribution of the
+whole must be on the terms of this License, whose permissions for other
+licensees extend to the entire whole, and thus to each and every part
+regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest your rights to
+work written entirely by you; rather, the intent is to exercise the right to
+control the distribution of derivative or collective works based on the
+Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of a
+storage or distribution medium does not bring the other work under the scope
+of this License.
+
+3. You may copy and distribute the Program (or a work based on it, under
+Section 2) in object code or executable form under the terms of Sections 1
+and 2 above provided that you also do one of the following:
+
+a) Accompany it with the complete corresponding machine-readable source
+code, which must be distributed under the terms of Sections 1 and 2 above
+on a medium customarily used for software interchange; or,
+
+b) Accompany it with a written offer, valid for at least three years, to give
+any third party, for a charge no more than your cost of physically performing
+source distribution, a complete machine-readable copy of the corresponding
+source code, to be distributed under the terms of Sections 1 and 2 above on
+a medium customarily used for software interchange; or,
+
+c) Accompany it with the information you received as to the offer to distribute
+corresponding source code. (This alternative is allowed only for
+noncommercial distribution and only if you received the program in object
+code or executable form with such an offer, in accord with Subsection b
+above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it. For an executable work, complete source code
+means all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation and
+installation of the executable. However, as a special exception, the source
+code distributed need not include anything that is normally distributed (in
+either source or binary form) with the major components (compiler, kernel,
+and so on) of the operating system on which the executable runs, unless that
+component itself accompanies the executable.
+
+If distribution of executable or object code is made by offering access to
+copy from a designated place, then offering equivalent access to copy the
+source code from the same place counts as distribution of the source code,
+even though third parties are not compelled to copy the source along with the
+object code.
+
+4. You may not copy, modify, sublicense, or distribute the Program except as
+expressly provided under this License. Any attempt otherwise to copy,
+modify, sublicense or distribute the Program is void, and will automatically
+terminate your rights under this License. However, parties who have received
+copies, or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+5. You are not required to accept this License, since you have not signed it.
+However, nothing else grants you permission to modify or distribute the
+Program or its derivative works. These actions are prohibited by law if you
+do not accept this License. Therefore, by modifying or distributing the
+Program (or any work based on the Program), you indicate your acceptance
+of this License to do so, and all its terms and conditions for copying,
+distributing or modifying the Program or works based on it.
+
+6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the original
+licensor to copy, distribute or modify the Program subject to these terms and
+conditions. You may not impose any further restrictions on the recipients'
+exercise of the rights granted herein. You are not responsible for enforcing
+compliance by third parties to this License.
+
+7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues), conditions
+are imposed on you (whether by court order, agreement or otherwise) that
+contradict the conditions of this License, they do not excuse you from the
+conditions of this License. If you cannot distribute so as to satisfy
+simultaneously your obligations under this License and any other pertinent
+obligations, then as a consequence you may not distribute the Program at all.
+For example, if a patent license would not permit royalty-free redistribution
+of the Program by all those who receive copies directly or indirectly through
+you, then the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply and
+the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any patents or
+other property right claims or to contest validity of any such claims; this
+section has the sole purpose of protecting the integrity of the free software
+distribution system, which is implemented by public license practices. Many
+people have made generous contributions to the wide range of software
+distributed through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing to
+distribute software through any other system and a licensee cannot impose
+that choice.
+
+This section is intended to make thoroughly clear what is believed to be a
+consequence of the rest of this License.
+
+8. If the distribution and/or use of the Program is restricted in certain
+countries either by patents or by copyrighted interfaces, the original copyright
+holder who places the Program under this License may add an explicit
+geographical distribution limitation excluding those countries, so that
+distribution is permitted only in or among countries not thus excluded. In such
+case, this License incorporates the limitation as if written in the body of this
+License.
+
+9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time. Such new versions will be
+similar in spirit to the present version, but may differ in detail to address new
+problems or concerns.
+
+Each version is given a distinguishing version number. If the Program specifies
+a version number of this License which applies to it and "any later version",
+you have the option of following the terms and conditions either of that
+version or of any later version published by the Free Software Foundation. If
+the Program does not specify a version number of this License, you may
+choose any version ever published by the Free Software Foundation.
+
+10. If you wish to incorporate parts of the Program into other free programs
+whose distribution conditions are different, write to the author to ask for
+permission. For software which is copyrighted by the Free Software
+Foundation, write to the Free Software Foundation; we sometimes make
+exceptions for this. Our decision will be guided by the two goals of
+preserving the free status of all derivatives of our free software and of
+promoting the sharing and reuse of software generally.
+
+ NO WARRANTY
+
+11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE,
+THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT
+PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE
+STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT
+WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED,
+INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
+OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND
+PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL
+NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR
+AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR
+ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE
+LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL,
+SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES
+ARISING OUT OF THE USE OR INABILITY TO USE THE
+PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA
+OR DATA BEING RENDERED INACCURATE OR LOSSES
+SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE
+PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN
+IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF
+THE POSSIBILITY OF SUCH DAMAGES.
+
+ END OF TERMS AND CONDITIONS
diff --git a/delta.info b/delta.info
index 6b28875..10d8cc2 100644
--- a/delta.info
+++ b/delta.info
@@ -2,7 +2,7 @@ name = Delta API
description = The Delta module is an advanced manipulation of the Theme Settings API to allow for customization/configuration of theme settings based on node types, context, or groups of paths.
package = Theme Tools
core = 7.x
+version = 7.x-3.x-dev
dependencies[] = context
-files[] = delta.module
diff --git a/delta.install b/delta.install
index 3a65f6e..1ee30cf 100644
--- a/delta.install
+++ b/delta.install
@@ -12,10 +12,10 @@ function delta_schema() {
$schema['delta_theme_settings'] = array(
'description' => t('Stores theme-settings templates that allow overriding the theme settings used based on various contexts.'),
'fields' => array(
- 'tid' => array(
- 'description' => 'The unique ID of the theme settings template',
- 'type' => 'serial',
- 'length' => 5,
+ 'machine_name' => array(
+ 'description' => 'The system name of this theme settings template.',
+ 'type' => 'varchar',
+ 'length' => 32,
'not null' => TRUE,
),
'name' => array(
@@ -23,47 +23,26 @@ function delta_schema() {
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
- 'default' => '',
- ),
- 'system_name' => array(
- 'description' => 'The system name of this theme settings template.',
- 'type' => 'varchar',
- 'length' => 128,
- 'not null' => TRUE,
- 'default' => '',
),
'theme' => array(
'description' => 'The theme for which this theme settings template is relevant.',
'type' => 'varchar',
'length' => 128,
'not null' => TRUE,
- 'default' => '',
),
- 'data' => array(
+ 'settings' => array(
'description' => t('Serialized data which is a copy of the theme settings array stored in the system table based on these overrides'),
- 'type' => 'text',
+ 'type' => 'blob',
'size' => 'big',
- 'not null' => TRUE,
+ 'not null' => FALSE,
'serialize' => TRUE,
),
),
- 'primary key' => array('tid'),
+ 'primary key' => array('machine_name'),
'indexes' => array(
'theme' => array('theme'),
- 'system_name' => array('system_name'),
- 'tid' => array('tid'),
),
);
return $schema;
-}
-
-/**
- * Implementation of hook_uninstall().
- */
-function delta_uninstall() {
- // Remove all skinr variables.
- db_delete('variable')
- ->condition('name', 'delta_%', 'LIKE')
- ->execute();
} \ No newline at end of file
diff --git a/delta.module b/delta.module
index 969b8f8..fe9df39 100644
--- a/delta.module
+++ b/delta.module
@@ -5,48 +5,168 @@
*/
/**
- * Implementation of hook_context_plugins().
- *
- * This is a ctools plugins hook.
+ * Implements hook_context_plugins().
*/
function delta_context_plugins() {
- $plugins = array();
- $plugins['context_reaction_delta'] = array(
- 'handler' => array(
- 'path' => drupal_get_path('module', 'delta') .'/plugins',
- 'file' => 'context_reaction_delta.inc',
- 'class' => 'context_reaction_delta',
- 'parent' => 'context_reaction',
+ return array(
+ 'context_reaction_delta' => array(
+ 'handler' => array(
+ 'path' => drupal_get_path('module', 'delta') . '/plugins',
+ 'file' => 'context_reaction_delta.inc',
+ 'class' => 'context_reaction_delta',
+ 'parent' => 'context_reaction',
+ ),
),
);
- return $plugins;
}
/**
- * Implementation of hook_context_registry().
+ * Implements hook_context_registry().
*/
function delta_context_registry() {
- $registry = array();
- $registry['reactions']['delta'] = array(
- 'title' => t('Delta'),
- 'description' => t('Apply contextual theme settings via the Delta module.'),
- 'plugin' => 'context_reaction_delta',
+ return array(
+ 'reactions' => array(
+ 'delta' => array(
+ 'title' => t('Delta'),
+ 'description' => t('Apply contextual theme settings via the Delta module.'),
+ 'plugin' => 'context_reaction_delta',
+ ),
+ ),
);
- return $registry;
}
/**
- * Implementation of hook_context_page_reaction().
+ * Implements hook_init().
+ */
+function delta_init() {
+ if ($plugin = context_get_plugin('reaction', 'delta')) {
+ $plugin->execute();
+ }
+}
+
+/**
+ * Implements hook_load().
+ */
+function delta_load($delta) {
+ $query = db_select('delta_theme_settings', 'dt')
+ ->fields('dt', array('machine_name', 'name', 'theme', 'settings'))
+ ->condition('machine_name', $delta)
+ ->execute()
+ ->fetchAll();
+
+ return reset($query);
+}
+
+/**
+ * @todo
+ */
+function delta_valid($delta, $key) {
+ return (bool) db_select('delta_theme_settings', 'dt')
+ ->condition('dt.theme', $key)
+ ->condition('dt.name', $delta)
+ ->range(0, 1)
+ ->countQuery()
+ ->execute();
+}
+
+/**
+ * @todo
+ */
+function delta_inject_settings($delta, $key) {
+ global $conf;
+
+ $conf['theme_' . $key . '_settings'] = delta_settings($delta, $key);
+}
+
+/**
+ * @todo
*/
-function delta_context_page_reaction() {
+function delta_layouts() {
+ return db_select('delta_theme_settings', 'dt')
+ ->fields('dt', array('machine_name', 'name', 'theme'))
+ ->orderBy('dt.name')
+ ->execute()
+ ->fetchAllAssoc('machine_name');
+}
+
+/**
+ * @todo
+ */
+function delta_settings($delta, $key) {
+ $delta = delta_load($delta);
+
+ return !empty($delta) ? unserialize($delta->settings) : delta_defaults($key);
+}
+
+/**
+ * @todo
+ */
+function delta_layout_options() {
+ $options = array();
+ foreach (delta_layouts() as $machine_name => $item) {
+ $options[$machine_name] = $item->name;
+ }
+ return $options;
}
/**
- * Implementation of hook_page_alter().
+ * @todo
*/
-function delta_preprocess_page(&$vars) {
- if ($plugin = context_get_plugin('reaction', 'delta')) {
- $plugin->execute($vars);
+function delta_save_settings($delta, $settings) {
+ return db_update('delta_theme_settings')
+ ->fields(array('settings' => serialize($settings)))
+ ->condition('machine_name', $delta)
+ ->execute();
+}
+
+/**
+ * @todo
+ */
+function delta_theme_options() {
+ $themes = list_themes();
+
+ $options = array();
+ foreach ($themes as $theme => $info) {
+ if ($info->status) {
+ $options[$theme] = $info->info['name'];
+ }
}
+
+ return $options;
+}
+
+/**
+ * @todo
+ */
+function delta_defaults($theme) {
+ // Fake theme_get_setting call for filling the static variable.
+ theme_get_setting('logo', $theme);
+
+ $settings = &drupal_static('theme_get_setting');
+
+ return isset($settings[$theme]) ? $settings[$theme] : array();
+}
+
+/**
+ * @todo
+ */
+function delta_save(&$item) {
+ if (!empty($item['old'])) {
+ drupal_write_record('delta_theme_settings', $item, 'machine_name');
+ }
+ else {
+ drupal_write_record('delta_theme_settings', $item);
+ }
+
+ return $item;
+}
+
+/**
+ * @todo
+ */
+function delta_delete($delta) {
+ return db_delete('delta_theme_settings')
+ ->condition('machine_name', $delta)
+ ->execute();
} \ No newline at end of file
diff --git a/delta_ui.admin.inc b/delta_ui.admin.inc
deleted file mode 100644
index fa480d9..0000000
--- a/delta_ui.admin.inc
+++ /dev/null
@@ -1,463 +0,0 @@
-<?php
-
-/**
- * @file
- * Delta UI functionality
- *
- * ===============================
- * ==== ========= ==============
- * ==== ========= ==============
- * ==== ========= === =========
- * ==== === === == === ==
- * == == = == === === = =
- * = = == == === ====== =
- * = = == ===== === ==== =
- * = = == = == === === = =
- * == === === === === =
- * ===============================
- *
- */
-
-/**
- * Menu callback; displays the delta listing page.
- */
-function delta_theme_settings_config($form, &$form_state) {
- drupal_set_title(t('Delta Theme Settings'));
- $form['delta'] = array(
- '#type' => 'fieldset',
- '#title' => t('Delta Theme API Settings & Configuration'),
- '#description' => t('In these default settings for <a href="http://himer.us/delta-module">Delta</a>, you can select which active themes will use contextual theme settings. Only enabled themes are listed here.'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- // get active themes for the settings form
- $filter_themes = FALSE;
- $themes = delta_get_themes_form_array($filter_themes);
- // create checkboxes to select themes that may be manipulated
- $form['delta']['delta_themes'] = array(
- '#type' => 'checkboxes',
- '#title' => t('Themes to manipulate'),
- '#options' => $themes,
- '#default_value' => variable_get('delta_themes', array()),
- '#description' => t('Here you may select the themes that should be manipulated by Delta. Only themes that are enabled will be listed. You can enable/disable themes via the <a href="'. base_path() .'admin/appearance">Theme Administration</a> page.'),
- );
- return system_settings_form($form);
-}
-
-
-/**
- * Menu callback;
- */
-function delta_layouts_view($theme_name = FALSE) {
- drupal_set_title(t('Delta Layouts'));
- $delta_layouts_list = drupal_get_form('delta_layouts_list', $theme_name);
- return render($delta_layouts_list);
-}
-
-/**
- * Menu callback; displays the delta listing page.
- */
-function delta_layouts_list($form, &$form_state) {
- $form = array();
- $form['delta'] = array(
- '#type' => 'vertical_tabs',
- '#weight' => 10,
- );
- $themes = delta_get_themes_array();
- foreach($themes AS $info) {
- // create fieldset for each theme we have the ability to manipulate
- $form['delta'][$info->name] = array(
- '#type' => 'fieldset',
- '#title' => t($info->info['name']),
- );
- // build the data for each theme, and it's theme settings templates
- $form['delta'][$info->name]['content'] = delta_get_layouts($info->name);
- }
- return $form;
-}
-
-/**
- * delta_get_layouts function.
- *
- * @access public
- * @param mixed $theme. (default: FALSE)
- * @return void
- * @todo Make the SQL SELECT statement conform to the PDO
- */
-function delta_get_layouts($theme = FALSE) {
- if (isset($theme)) {
- $header = array(t('Name'), array('data' => t('Operations'), 'colspan' => '3'));
- $rows = array();
- $sql = "
- SELECT dt.name, dt.system_name, dt.tid
- FROM {delta_theme_settings} dt
- WHERE dt.theme = :theme
- ORDER BY dt.name ASC";
- $result = db_query($sql, array(':theme' => $theme), array('fetch' => PDO::FETCH_ASSOC));
- foreach ($result as $item) {
- $row = array(
- 'name' => '<h3>' . $item['name'] . '</h3><span class="description"><strong>' . t('Machine Name: ') . '</strong><em>' . $item['system_name'] . '</em></span>',
- 'edit' => l(t('Edit'), 'admin/appearance/delta/layouts/edit/' . $item['system_name']),
- 'configure' => l(t('Configure'), 'admin/appearance/delta/layouts/configure/' . $item['system_name']),
- 'delete' => l(t('Delete'), 'admin/appearance/delta/layouts/delete/' . $item['system_name']),
- );
- $rows[] = $row;
- }
- $build['table'] = array(
- '#theme' => 'table',
- '#header' => $header,
- '#rows' => $rows,
- '#empty' => t('No theme settings templates available. <a href="@link">Add layout</a>.', array('@link' => url('admin/appearance/delta/layouts/add'))),
- );
- return $build;
- }
- return FALSE;
-}
-
-
-
-
-/**
- * delta_get_layout_data function.
- *
- * @access public
- * @param mixed $layout
- * @return void
- * @todo Make the SQL SELECT statement conform to the PDO
- */
-function delta_get_layout_data($layout) {
- $sql = "
- SELECT dt.name, dt.system_name, dt.tid, dt.data, dt.theme
- FROM {delta_theme_settings} dt
- WHERE dt.system_name = :layout
- LIMIT 1";
- $result = db_query($sql, array(':layout' => $layout), array('fetch' => PDO::FETCH_ASSOC));
- foreach ($result as $item) {
- $data = $item;
- }
- return $data;
-}
-
-/**
- * Form callback for creating and editing theme settings templates
- *
- * @param $form
- * @param $form_state
- */
-
-function delta_layout_edit($form, &$form_state, $layout = FALSE) {
- if($layout) {
- //drupal_set_message('we are editing <strong>' . $layout . '</strong>.');
- $data = delta_get_layout_data($layout);
- }
- $form = array();
-
-
- if(isset($form_state['build_info']['args'][0])) {
- drupal_set_title(t('Edit Delta Layout'));
- $edit = $form_state['build_info']['args'][0];
- }
- else {
- drupal_set_title(t('Add Delta Layout'));
- }
-
- $form['delta'] = array(
- '#type' => 'vertical_tabs',
- '#weight' => -100,
- '#prefix' => '',
- '#suffix' => '<div id="theme_settings_replace"></div>',
- );
- $form['delta']['settings'] = array(
- '#type' => 'fieldset',
- '#title' => t('Layout Settings'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- $form['delta']['settings']['tid'] = array(
- '#type' => 'value',
- '#value' => isset($data['tid']) ? $data['tid'] : NULL,
- );
- $form['delta']['settings']['title'] = array(
- '#type' => 'textfield',
- '#title' => t('Name of Layout'),
- '#required' => TRUE,
- '#size' => 32,
- '#default_value' => isset($data['name']) ? $data['name'] : NULL,
- );
- $form['delta']['settings']['name'] = array(
- '#type' => 'machine_name',
- '#title' => t('System name'),
- '#default_value' => isset($data['system_name']) ? $data['system_name'] : NULL,
- '#maxlength' => 64,
- '#description' => t('A unique name to construct the URL for the template. It must only contain lowercase letters, numbers and hyphens.'),
- '#machine_name' => array(
- 'exists' => 'delta_layout_name_exists',
- 'source' => array('delta', 'settings', 'title'),
- 'label' => t('System Name'),
- 'replace_pattern' => '[^a-z0-9-]+',
- 'replace' => '-',
- ),
- '#disabled' => isset($data['tid']) ? TRUE : FALSE,
- );
- $allowed_themes = variable_get('delta_themes', array());
- $themes = delta_get_themes_form_array($allowed_themes);
- $form['delta']['settings']['theme'] = array(
- '#type' => 'select',
- '#title' => t('Theme'),
- '#default_value' => isset($data['theme']) ? $data['theme'] : NULL,
- '#options' => array('none' => 'Select Theme') + $themes,
- /*
- '#ajax' => array(
- 'callback' => 'delta_load_theme_settings_callback',
- 'wrapper' => 'theme_settings_replace',
- 'method' => 'replace',
- 'effect' => 'fade',
- ), */
- // disable changing the theme this is associated with after creation
- // you would need to create a new one to do something like that. :P
- '#disabled' => isset($data['tid']) ? TRUE : FALSE,
- );
- /*
- $form['delta']['overrides'] = array(
- '#type' => 'fieldset',
- '#title' => t('Theme Settings Overrides'),
- '#collapsible' => TRUE,
- '#collapsed' => FALSE,
- );
- if (isset($data['theme'])) {
- $form['delta']['overrides']['custom'] = delta_load_theme_settings_callback($form, $form_state, $data['theme']);
- }
- */
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save'),
- );
- // Only custom theme setting templates may be deleted.
- /*
- $form['actions']['delete'] = array(
- '#type' => 'submit',
- '#value' => t('Delete'),
- //'#access' => isset($edit) ? TRUE : FALSE,
- );
- */
- //krumo($form);
- return $form;
-}
-
-/**
- * delta_template_configure function.
- *
- * @access public
- * @param mixed $form
- * @param mixed &$form_state
- * @param mixed $layout. (default: FALSE)
- * @return void
- */
-function delta_layout_configure($form, &$form_state, $layout = FALSE) {
- if($layout) {
- $data = delta_get_layout_data($layout);
- drupal_set_title(t('Editing '. $data['name']));
- }
- if (isset($data['theme'])) {
-
- $form = delta_load_theme_settings_callback($data['theme'], $layout);
-
- $form['#submit'] = array('delta_ui_layout_configure_submit');
- $form['#validate'] = array('delta_ui_layout_configure_validate');
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save Layout'),
- );
- return $form;
- }
- return 'Error Loading Theme Settings form...';
-}
-
-
-/**
- * delta_template_configure function.
- *
- * @access public
- * @param mixed $form
- * @param mixed &$form_state
- * @param mixed $layout. (default: FALSE)
- * @return void
- */
-function delta_layout_delete($form, &$form_state, $layout = FALSE) {
- if($layout) {
- $data = delta_get_layout_data($layout);
- drupal_set_title(t('Deleting '. $data['name']));
- }
- if (isset($data['theme'])) {
-
- $form = array();
- $form['tid'] = array(
- '#type' => 'value',
- '#value' => isset($data['tid']) ? $data['tid'] : NULL,
- );
- $form['template_delete'] = array(
- '#markup' => '<p><strong>WARNING:</strong> Deleting this theme settings layout will immediately make it unavailable.</p>',
- );
- $form['#submit'] = array('delta_ui_layout_delete_submit');
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Delete Layout'),
- );
- return $form;
- }
- return 'Error Loading Theme Settings form...';
-}
-
-
-function delta_load_theme_settings_callback($theme, $layout) {
- if ($theme != 'none') {
- $key = $theme;
- $var = 'theme_delta_' . $layout . '_settings';
- $themes = system_rebuild_theme_data();
- $features = $themes[$key]->info['features'];
- $form = array();
- $form_state['build_info']['args'][0] = $key;
- // Call engine-specific settings.
- $function = $themes[$key]->prefix . '_engine_settings';
- if (function_exists($function)) {
- $form['engine_specific'] = array(
- '#type' => 'fieldset',
- '#title' => t('Theme-engine-specific settings'),
- '#description' => t('These settings only exist for the themes based on the %engine theme engine.', array('%engine' => $themes[$key]->prefix)),
- );
- $function($form, $form_state);
- }
- // create the variable we will store the data in.
- $form['var'] = $form['delta_template'] = array('#type' => 'hidden', '#value' => $var);
- // Create a list which includes the current theme and all its base themes.
- if (isset($themes[$key]->base_themes)) {
- $theme_keys = array_keys($themes[$key]->base_themes);
- $theme_keys[] = $key;
- }
- else {
- $theme_keys = array($key);
- }
-
- // Save the name of the current theme (if any), so that we can temporarily
- // override the current theme and allow theme_get_setting() to work
- // without having to pass the theme name to it.
- $default_theme = !empty($GLOBALS['theme_key']) ? $GLOBALS['theme_key'] : NULL;
- $GLOBALS['theme_key'] = $key;
-
- // Process the theme and all its base themes.
- foreach ($theme_keys as $theme) {
- // Include the theme-settings.php file.
- $filename = DRUPAL_ROOT . '/' . str_replace("/$theme.info", '', $themes[$theme]->filename) . '/theme-settings.php';
- if (file_exists($filename)) {
- require_once $filename;
- }
-
- // Call theme-specific settings.
- $function = $theme . '_form_system_theme_settings_alter';
- if (function_exists($function)) {
- $function($form, $form_state, $theme);
- }
- }
-
- // Restore the original current theme.
- if (isset($default_theme)) {
- $GLOBALS['theme_key'] = $default_theme;
- }
- else {
- unset($GLOBALS['theme_key']);
- }
- //krumo($form);
- //$variable = variable_get('theme_delta_omega_starterkit_omega-starterkit-home-layout_settings');
- //krumo($variable);
-
- //module_load_include('inc', 'system', 'system.admin');
- //$form = drupal_get_form('system_theme_settings', $theme);
- return $form;
- }
- else {
- return t('<div id="theme_settings_replace"><p>Unable to load theme settings form group... WTF...</p></div>');
- }
-}
-
-
-/**
- * Validation handler for delta_template_edit()
- *
- * This validation handler checks to ensure a theme has been selected.
- *
- * @param $form
- * @param $form_state
- */
-function delta_layout_edit_validate($form, &$form_state) {
- $values = $form_state['values'];
- //dsm($values);
- if ($values['theme'] == 'none') {
- form_set_error('theme', t('You must select a theme in order to create a theme settings template. The settings stored are based on the default theme settings of the selected theme.'));
- }
-}
-
-/**
- * Submit handler for delta_template_edit()
- *
- * This submit handler will insert or update the database with the appropriate
- * settings provided by the form submission.
- *
- * @param $form
- * @param $form_state
- */
-function delta_layout_edit_submit($form, &$form_state) {
- $values = $form_state['values'];
- $item = array(
- 'tid' => isset($values['tid']) ? $values['tid'] : FALSE,
- 'name' => check_plain($values['title']),
- 'system_name' => check_plain($values['name']),
- 'theme' => check_plain($values['theme']),
- 'data' => array(),
- );
- // save record
- if ($item['tid']) {
- drupal_write_record('delta_theme_settings', $item, 'tid');
- }
- else {
- drupal_write_record('delta_theme_settings', $item);
- }
-
- drupal_set_message('The custom theme settings layout <strong>' . $item['name'] . '</strong> has been saved for <em>'. $item['theme'] .'</em>...');
- drupal_set_message('You may now configure the <strong>' . $item['name'] . '</strong> theme settings layout.');
- drupal_goto('admin/appearance/delta/layouts/configure/'. $item['system_name']);
-}
-
-/**
- * Helper function for machine readable names in {delta_theme_settings}
- * @param $t
- */
-function delta_layout_name_exists($t) {
- $exists = db_query_range('SELECT 1 FROM {delta_theme_settings} WHERE system_name = :name', 0, 1, array(':name' => $t))->fetchField();
- return $exists;
-}
-
-/**
- * Menu callback; displays the delta listing page.
- */
-function delta_overrides_list($form, &$form_state) {
- drupal_set_title(t('Delta Overrides'));
- //krumo($form_state);
- $theme = isset($form_state['build_info']['args'][0]) ? $form_state['build_info']['args'][0] : FALSE;
- $themes = list_themes();
- //krumo($themes);
- if($theme) {
- drupal_set_title(t('Delta Overrides for ' . $themes[$theme]->info['name']));
- }
-
- $form['actions'] = array('#type' => 'actions');
- $form['actions']['submit'] = array(
- '#type' => 'submit',
- '#value' => t('Save'),
- );
- return $form;
-} \ No newline at end of file
diff --git a/delta_ui.js b/delta_ui.js
deleted file mode 100644
index 46d934b..0000000
--- a/delta_ui.js
+++ /dev/null
@@ -1,3 +0,0 @@
-(function ($) {
-
-})(jQuery);
diff --git a/delta_ui.module b/delta_ui.module
deleted file mode 100644
index eea9c7a..0000000
--- a/delta_ui.module
+++ /dev/null
@@ -1,227 +0,0 @@
-<?php
-/**
- * Implementation of hook_menu().
- */
-
-/**
- * Implementation of hook_permission().
- */
-function delta_ui_permission() {
- return array(
- 'administer delta' => array(
- 'title' => t('Administer Delta'),
- 'description' => t('Administer settings for the Delta module.'),
- ),
- );
-}
-
-/**
- * Implementation of hook_menu().
- */
-function delta_ui_menu() {
- $items['admin/appearance/delta'] = array(
- 'title' => 'Delta',
- 'description' => 'Manage your delta settings and rules, import and export delta settings for each theme',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('delta_theme_settings_config'),
- 'access arguments' => array('administer delta'),
- 'file' => 'delta_ui.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- );
- $items['admin/appearance/delta/settings'] = array(
- 'title' => 'Settings',
- 'description' => 'Manage Delta settings.',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'parent' => 'admin/appearance/delta',
- 'weight' => -10,
- );
-
-
- $items['admin/appearance/delta/layouts'] = array(
- 'title' => 'Layouts',
- 'description' => 'Manage theme setting layouts.',
- 'page callback' => 'delta_layouts_view',
- 'access arguments' => array('administer delta'),
- 'file' => 'delta_ui.admin.inc',
- 'type' => MENU_LOCAL_TASK,
- 'parent' => 'admin/appearance/delta',
- );
- $items['admin/appearance/delta/layouts/list'] = array(
- 'title' => 'List',
- 'description' => 'Manage your theme setting layouts.',
- 'type' => MENU_DEFAULT_LOCAL_TASK,
- 'parent' => 'admin/appearance/delta/layouts',
- 'weight' => -1,
- );
-
- $items['admin/appearance/delta/layouts/add'] = array(
- 'title' => 'Add Template',
- 'description' => 'Create a new theme setting layout.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('delta_layout_edit'),
- 'access arguments' => array('administer delta'),
- 'file' => 'delta_ui.admin.inc',
- 'type' => MENU_LOCAL_ACTION,
- 'parent' => 'admin/appearance/delta/layouts',
- );
-
- $items['admin/appearance/delta/layouts/edit/%'] = array(
- 'title' => 'Edit',
- 'description' => 'Edit a Theme Settings Layout.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('delta_layout_edit', 5),
- 'access arguments' => array('administer delta'),
- 'file' => 'delta_ui.admin.inc',
- 'type' => MENU_NORMAL_ITEM,
- 'tab_parent' => 'admin/appearance/delta/layouts',
- );
-
- $items['admin/appearance/delta/layouts/configure/%'] = array(
- 'title' => 'Settings',
- 'description' => 'Override settings for Layout.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('delta_layout_configure', 5),
- 'access arguments' => array('administer delta'),
- 'file' => 'delta_ui.admin.inc',
- 'type' => MENU_NORMAL_ITEM,
- 'tab_parent' => 'admin/appearance/delta/layouts',
- );
- $items['admin/appearance/delta/layouts/delete/%'] = array(
- 'title' => 'Delete',
- 'description' => 'Delete Theme Settings Layout.',
- 'page callback' => 'drupal_get_form',
- 'page arguments' => array('delta_layout_delete', 5),
- 'access arguments' => array('administer delta'),
- 'file' => 'delta_ui.admin.inc',
- 'type' => MENU_NORMAL_ITEM,
- 'tab_parent' => 'admin/appearance/delta/layouts',
- );
- return $items;
-}
-
-
-/**
- * Pull data from actively selected themes
- * @return the full theme array as normally pulled by list_themes(), but filters out the inactive themes.
- */
-function delta_get_themes_array() {
- $system_themes = list_themes();
- $themes = array();
- $configurable_themes = variable_get('delta_themes', array());
- if (is_array($system_themes)) {
- foreach ($system_themes AS $name => $theme) {
- // let's gather active themes only, and the ones that have been set in Delta API global settings
- if ($theme->status == 1 && isset($configurable_themes[$theme->name]) && $configurable_themes[$theme->name]) {
- $themes[$name] = $theme;
- }
- }
- return $themes;
- }
- return FALSE;
-}
-
-/**
- * Pull data from actively selected themes
- * @return a usable array of theme data for use in forms for checkboxes or radio buttons
- */
-function delta_get_themes_form_array(&$filter) {
- $system_themes = list_themes();
- $configurable_themes = variable_get('delta_themes', array());
- $themes = array();
- if (is_array($system_themes)) {
- foreach ($system_themes AS $name => $theme) {
- // let's gather active themes only
- if (!$filter) {
- if ($theme->status == 1) {
- $themes[$name] = $theme->info['name'];
- }
- }
- else {
- if ($theme->status == 1 && isset($configurable_themes[$theme->name]) && $configurable_themes[$theme->name]) {
- $themes[$name] = $theme->info['name'];
- }
- }
- }
- return $themes;
- }
- return FALSE;
-}
-
-/**
- * Called when saving the default delta settings form.
- * This is needed to rebuild the menu when an update occurs in order to
- * Add/Remove any themes that need to be in the menu system for rendering
- * the appropriate sub-tabs.
- */
-function delta_menu_rebuild() {
- menu_rebuild();
- menu_cache_clear_all();
-}
-
-
-/**
- * Implmentation of hook_form_alter for delta_theme_settings_config()
- * @return $form
- * @see http://api.drupal.org/api/function/hook_form_FORM_ID_alter/6
- * @see http://api.drupal.org/api/function/hook_form_alter/6
- */
-function delta_form_delta_theme_settings_config_alter(&$form, &$form_state) {
- // adding submit handler to rebuild the menu on submitting this form
- $form['#submit'][] = 'delta_menu_rebuild';
-}
-
-function delta_ui_form_delta_layout_configure_alter($form, &$form_state) {
-
-}
-
-function delta_ui_layout_configure_submit($form, &$form_state) {
- $values = $form_state['values'];
- $values = $form_state['values'];
- $key = $values['var'];
-
- unset(
- $values['var'],
- $values['submit'],
- $values['reset'],
- $values['form_id'],
- $values['op'],
- $values['form_build_id'],
- $values['form_token'],
- $values['toggle_logo'],
- $values['toggle_name'],
- $values['toggle_slogan'],
- $values['toggle_node_user_picture'],
- $values['toggle_comment_user_picture'],
- $values['toggle_comment_user_verification'],
- $values['toggle_favicon'],
- $values['toggle_main_menu'],
- $values['toggle_secondary_menu'],
- $values['default_logo'],
- $values['logo_path'],
- $values['logo_upload'],
- $values['default_favicon'],
- $values['favicon_path'],
- $values['favicon_upload'],
- $values['theme_settings_export_code']
- );
-
- variable_set($key, $values);
- drupal_set_message(t('The configuration options have been saved.'));
- cache_clear_all();
-}
-
-function delta_ui_layout_delete_submit($form, &$form_state) {
- $values = $form_state['values'];
- $key = $values['tid'];
- variable_del($key, $values);
- db_delete('delta_theme_settings')
- ->condition('tid', $key)
- ->execute();
- drupal_set_message(t('The item has been deleted.'));
- cache_clear_all();
- drupal_goto('admin/appearance/delta/layouts');
-}
-
-function delta_ui_layout_configure_validate($form, &$form_state) {
-
-} \ No newline at end of file
diff --git a/delta_ui/delta_ui.admin.inc b/delta_ui/delta_ui.admin.inc
new file mode 100644
index 0000000..10ea75f
--- /dev/null
+++ b/delta_ui/delta_ui.admin.inc
@@ -0,0 +1,188 @@
+<?php
+
+/**
+ * @file
+ * Delta UI functionality
+ */
+
+/**
+ * @todo
+ */
+function delta_ui_layouts_page($theme_name = FALSE) {
+ $themes = list_themes();
+ $header = array(t('Title'), t('Machine name'), array('data' => t('Operations'), 'colspan' => '3'));
+
+ $form['themes'] = array(
+ '#type' => 'vertical_tabs',
+ '#tree' => TRUE,
+ '#weight' => -10,
+ );
+
+ foreach ($themes as $theme => $info) {
+ if ($info->status) {
+ $form['themes'][$theme] = array(
+ '#type' => 'fieldset',
+ '#title' => $info->info['name'],
+ );
+
+ $form['themes'][$theme]['content'] = array(
+ '#theme' => 'table',
+ '#header' => $header,
+ '#rows' => array(),
+ '#empty' => t('There are no theme settings templates availabe for %theme. <a href="@link" title="Add a layout">Add a layout</a>.', array('%theme' => $themes[$theme]->info['name'], '@link' => url('admin/appearance/delta/layouts/add'))),
+ );
+ }
+ }
+
+ foreach (delta_layouts() as $layout => $info) {
+ if (isset($themes[$info->theme]) && $themes[$info->theme]->status) {
+ $form['themes'][$info->theme]['content']['#rows'][] = array(
+ 'title' => $info->name,
+ 'name' => $info->machine_name,
+ 'edit' => l(t('Edit'), 'admin/appearance/delta/layouts/edit/' . $info->machine_name),
+ 'configure' => l(t('Configure'), 'admin/appearance/delta/layouts/configure/' . $info->machine_name),
+ 'delete' => l(t('Delete'), 'admin/appearance/delta/layouts/delete/' . $info->machine_name),
+ );
+ }
+ }
+
+ return $form;
+}
+
+/**
+ * @todo
+ */
+function delta_ui_layout_edit($form, &$form_state, $layout = NULL) {
+ if(isset($layout)) {
+ drupal_set_title(t('Edit Delta Layout'));
+ }
+ else {
+ drupal_set_title(t('Add Delta Layout'));
+ }
+
+ $form['old'] = array(
+ '#type' => 'value',
+ '#value' => $layout,
+ );
+
+ $form['name'] = array(
+ '#type' => 'textfield',
+ '#title' => t('Title'),
+ '#description' => t('@todo'),
+ '#default_value' => isset($form_state['values']['name']) ? $form_state['values']['name'] : '',
+ '#required' => TRUE,
+ );
+
+ $form['machine_name'] = array(
+ '#type' => 'machine_name',
+ '#title' => t('Machine name'),
+ '#description' => t('A unique machine-readable name for this theme settings template. It must only contain lowercase letters, numbers, and hyphens.'),
+ '#default_value' => isset($form_state['values']['machine_name']) ? $form_state['values']['machine_name'] : '',
+ '#required' => TRUE,
+ '#maxlength' => 32,
+ '#disabled' => isset($layout),
+ '#machine_name' => array(
+ 'exists' => 'delta_load',
+ 'replace_pattern' => '[^a-z0-9-]+',
+ 'replace' => '-',
+ ),
+ );
+
+ $form['theme'] = array(
+ '#type' => 'select',
+ '#title' => t('Theme'),
+ '#required' => TRUE,
+ '#description' => t('@todo'),
+ '#default_value' => isset($form_state['values']['theme']) ? $form_state['values']['theme'] : '',
+ '#options' => delta_theme_options(),
+ '#disabled' => isset($layout),
+ );
+
+ $form['submit'] = array(
+ '#type' => 'submit',
+ '#value' => t('Save'),
+ '#submit' => array('delta_ui_layout_edit_submit'),
+ );
+
+ return $form;
+}
+
+/**
+ * @todo
+ */
+function delta_ui_layout_edit_submit($form, &$form_state) {
+ $values = $form_state['values'];
+ $themes = list_themes();
+
+ $values['settings'] = delta_settings($values['machine_name'], $values['theme']);
+
+ delta_save($values);
+
+ drupal_set_message(t('The custom theme settings layout <strong>@name</strong> has been saved for %theme.', array('@name' => $values['name'], '%theme' => $themes[$values['theme']]->info['name'])));
+ drupal_set_message(t('You may now configure the <strong>@name</strong> theme settings layout.', array('@name' => $values['name'])));
+
+ drupal_goto('admin/appearance/delta/layouts/configure/' . $values['machine_name']);
+}
+
+/**
+ * @todo
+ */
+function delta_ui_layout_configure($form, &$form_state, $layout) {
+ module_load_include('inc', 'system', 'system.admin');
+ delta_inject_settings($layout->machine_name, $layout->theme);
+
+ $form_state['delta'] = $layout->machine_name;
+ $form_state['build_info']['args'][0] = $layout->theme;
+
+ $form = system_theme_settings($form, &$form_state, $layout->theme);
+
+ $system = array_search('system_theme_settings_submit', $form['#submit']);
+ $form['#submit'][$system] = 'delta_ui_layout_configure_submit';
+
+ return $form;
+}
+
+/**
+ * @todo
+ */
+function delta_ui_layout_configure_submit($form, &$form_state) {
+ $theme = $form_state['build_info']['args'][0];
+ $backup = variable_get('theme_' . $theme . '_settings');
+ $values = $form_state['values'];
+ $key = $values['var'];
+
+ unset($values['var'], $values['submit'], $values['reset'], $values['form_id'], $values['op'], $values['form_build_id'], $values['form_token']);
+
+ system_theme_settings_submit($form, &$form_state);
+ variable_set($key, $backup);
+ delta_save_settings($form_state['delta'], $values);
+}
+
+/**
+ * @todo
+ */
+function delta_layout_delete_confirm($form, &$form_state, $layout = NULL) {
+ $form_state['layout'] = $layout;
+
+ return confirm_form($form,
+ t('Are you sure you want to delete this template?'),
+ 'admin/appearance/delta',
+ t('This action cannot be undone.'),
+ t('Delete'),
+ t('Cancel')
+ );
+}
+
+/**
+ * @todo
+ */
+function delta_layout_delete_confirm_submit($form, &$form_state) {
+ if ($form_state['values']['confirm']) {
+ $layout = $form_state['layout'];
+
+ delta_delete($layout->machine_name);
+ drupal_set_message(t('The layout %name has been deleted.', array('%name' => $layout->name)));
+ }
+
+ $form_state['redirect'] = 'admin/structure/vote';
+} \ No newline at end of file
diff --git a/delta_ui.info b/delta_ui/delta_ui.info
index 710ff09..50ec56b 100644
--- a/delta_ui.info
+++ b/delta_ui/delta_ui.info
@@ -2,8 +2,6 @@ name = Delta UI
description = The Delta UI provides a user interface to build and edit the contextual theme settings provided by the Delta module.
package = Theme Tools
core = 7.x
+version = 7.x-3.x-dev
dependencies[] = delta
-
-files[] = delta_ui.module
-scripts[] = delta_ui.js \ No newline at end of file
diff --git a/delta_ui/delta_ui.module b/delta_ui/delta_ui.module
new file mode 100644
index 0000000..bf8ddf6
--- /dev/null
+++ b/delta_ui/delta_ui.module
@@ -0,0 +1,95 @@
+<?php
+
+/**
+ * Implementation of hook_permission().
+ */
+function delta_ui_permission() {
+ return array(
+ 'administer delta' => array(
+ 'title' => t('Administer Delta'),
+ 'description' => t('Administer settings for the Delta module.'),
+ ),
+ );
+}
+
+/**
+ * Implementation of hook_menu().
+ */
+function delta_ui_menu() {
+ $items['admin/appearance/delta'] = array(
+ 'title' => 'Delta',
+ 'description' => 'Manage your delta settings and rules, import and export delta settings for each theme',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('delta_ui_layouts_page'),
+ 'access arguments' => array('administer delta'),
+ 'file' => 'delta_ui.admin.inc',
+ 'file' => 'delta_ui.admin.inc',
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ $items['admin/appearance/delta/layouts'] = array(
+ 'title' => 'Layouts',
+ 'description' => 'Manage theme setting layouts.',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -10,
+ );
+
+ $items['admin/appearance/delta/settings'] = array(
+ 'title' => 'Settings',
+ 'description' => 'Manage Delta settings.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('delta_ui_theme_settings_config'),
+ 'access arguments' => array('administer delta'),
+ 'file' => 'delta_ui.admin.inc',
+ 'type' => MENU_LOCAL_TASK,
+ );
+
+ $items['admin/appearance/delta/layouts/list'] = array(
+ 'title' => 'List',
+ 'description' => 'Manage your theme setting layouts.',
+ 'type' => MENU_DEFAULT_LOCAL_TASK,
+ 'weight' => -1,
+ );
+
+ $items['admin/appearance/delta/layouts/add'] = array(
+ 'title' => 'Add Template',
+ 'description' => 'Create a new theme setting layout.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('delta_ui_layout_edit'),
+ 'access arguments' => array('administer delta'),
+ 'file' => 'delta_ui.admin.inc',
+ 'type' => MENU_LOCAL_ACTION,
+ );
+
+ $items['admin/appearance/delta/layouts/edit/%delta'] = array(
+ 'title' => 'Edit',
+ 'description' => 'Edit a theme settings layout.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('delta_ui_layout_edit', 5),
+ 'access arguments' => array('administer delta'),
+ 'file' => 'delta_ui.admin.inc',
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
+ $items['admin/appearance/delta/layouts/configure/%delta'] = array(
+ 'title' => 'Settings',
+ 'description' => 'Override settings for a layout.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('delta_ui_layout_configure', 5),
+ 'access arguments' => array('administer delta'),
+ 'file' => 'delta_ui.admin.inc',
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
+ $items['admin/appearance/delta/layouts/delete/%delta'] = array(
+ 'title' => 'Delete',
+ 'description' => 'Delete theme settings layout.',
+ 'page callback' => 'drupal_get_form',
+ 'page arguments' => array('delta_ui_layout_delete', 5),
+ 'access arguments' => array('administer delta'),
+ 'file' => 'delta_ui.admin.inc',
+ 'type' => MENU_NORMAL_ITEM,
+ );
+
+ return $items;
+} \ No newline at end of file
diff --git a/plugins/context_reaction_delta.inc b/plugins/context_reaction_delta.inc
index e4afd14..05dbe82 100644
--- a/plugins/context_reaction_delta.inc
+++ b/plugins/context_reaction_delta.inc
@@ -5,48 +5,40 @@
*/
class context_reaction_delta extends context_reaction {
/**
- * ugh
+ * @todo
*/
function options_form($context) {
$values = $this->fetch_from_context($context);
+ $options = delta_layout_options();
+
$form = array(
'#tree' => TRUE,
'#title' => t('Delta Override Template'),
- );
-
- $sql = "
- SELECT dt.name, dt.system_name, dt.tid
- FROM {delta_theme_settings} dt
- ORDER BY dt.name ASC";
- $result = db_query($sql, array(), array('fetch' => PDO::FETCH_ASSOC));
- $options = array();
- foreach ($result as $item) {
- $options[$item['system_name']] = $item['name'];
- }
-
- $form['delta_template'] = array(
- '#type' => 'radios',
- '#title' => t('Select Custom theme settings template.'),
- '#default_value' => isset($values['delta_template']) ? $values['delta_template'] : '',
- '#options' => $options,
- );
+ );
+
+ $form['delta'] = array(
+ '#type' => count($options) > 10 ? 'select' : 'radios',
+ '#title' => t('Select Custom theme settings template.'),
+ '#default_value' => isset($values['delta']) ? $values['delta'] : '',
+ '#options' => $options,
+ '#required' => TRUE,
+ );
+
return $form;
}
/**
- * Set 'section_title', and 'section_subtitle' if not set and merge all
- * additional classes onto the 'body_classes'.
+ * @todo
*/
- function execute(&$vars) {
- $contexts = context_active_contexts();
- foreach ($contexts as $context) {
- if (!empty($context->reactions['delta'])) {
- // add the delta override variable to the $vars so it can be used in omega_preprocess
- $vars['delta'] = 'theme_delta_'.$context->reactions['delta']['delta_template'].'_settings';
- // allow delta to load it's own custom form data, emulating a custom theme.
- GLOBAL $delta_template;
- $delta_template = isset($vars['delta']) ? $vars['delta'] : NULL;
+ function execute() {
+ global $delta, $theme_key;
+
+ foreach (context_active_contexts() as $context) {
+ if (!empty($context->reactions['delta']) && delta_valid($context->reactions['delta'], $theme_key)) {
+ $delta = $context->reactions['delta']['delta'];
+
+ delta_inject_settings($delta, $theme_key);
}
- }
+ }
}
}