Loading tilt_js.module +56 −0 Original line number Diff line number Diff line Loading @@ -141,3 +141,59 @@ function tilt_js_permission() { ), ); } /** * Implements hook_ctools_plugin_api(). */ function tilt_js_ctools_plugin_api($owner, $api) { if ($owner == 'tilt_js' && $api == 'tilt_js_default_preset') { return array('version' => 1); } } /** * Fetches the given optionset object identified by $id. * * @param string $id * The optionset ID. * * @return object * Returns the optionset, or else default, if no optionset found. */ function tilt_js_optionset_load($id) { ctools_include('export'); $optionset = ctools_export_crud_load('tilt_js_optionset', $id); // Ensures deleted optionset while being used doesn't screw up. if (!isset($optionset->name)) { $optionset = ctools_export_crud_load('tilt_js_optionset', 'default'); watchdog('slick', 'Fallback to default optionset.', array(), WATCHDOG_WARNING); } return $optionset; } /** * Creates a new optionset object without saving it to the database. * * @param array $values * The values to build the optionset if provided. * * @return object * Returns the programmatically created optionset object. */ function tilt_js_optionset_create($values = array()) { ctools_include('export'); $optionset = ctools_export_crud_new('tilt_js_optionset'); $optionset->options = $optionset->options['settings'] = array(); foreach (array('name', 'label', 'options') as $key) { if (isset($values[$key])) { $optionset->{$key} = $values[$key]; } } $defaults['settings'] = tilt_js_get_options(); $optionset->options = $optionset->options + $defaults; return $optionset; } Loading
tilt_js.module +56 −0 Original line number Diff line number Diff line Loading @@ -141,3 +141,59 @@ function tilt_js_permission() { ), ); } /** * Implements hook_ctools_plugin_api(). */ function tilt_js_ctools_plugin_api($owner, $api) { if ($owner == 'tilt_js' && $api == 'tilt_js_default_preset') { return array('version' => 1); } } /** * Fetches the given optionset object identified by $id. * * @param string $id * The optionset ID. * * @return object * Returns the optionset, or else default, if no optionset found. */ function tilt_js_optionset_load($id) { ctools_include('export'); $optionset = ctools_export_crud_load('tilt_js_optionset', $id); // Ensures deleted optionset while being used doesn't screw up. if (!isset($optionset->name)) { $optionset = ctools_export_crud_load('tilt_js_optionset', 'default'); watchdog('slick', 'Fallback to default optionset.', array(), WATCHDOG_WARNING); } return $optionset; } /** * Creates a new optionset object without saving it to the database. * * @param array $values * The values to build the optionset if provided. * * @return object * Returns the programmatically created optionset object. */ function tilt_js_optionset_create($values = array()) { ctools_include('export'); $optionset = ctools_export_crud_new('tilt_js_optionset'); $optionset->options = $optionset->options['settings'] = array(); foreach (array('name', 'label', 'options') as $key) { if (isset($values[$key])) { $optionset->{$key} = $values[$key]; } } $defaults['settings'] = tilt_js_get_options(); $optionset->options = $optionset->options + $defaults; return $optionset; }