Skip to content

Commit

Permalink
Merge pull request #7 from oui-textpattern/backup
Browse files Browse the repository at this point in the history
Rework #2 + improvements
  • Loading branch information
Nicolas Morand committed Jun 21, 2018
2 parents aaf910c + 294c697 commit 2b110d4
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 615 deletions.
42 changes: 29 additions & 13 deletions src/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,17 @@ public function __construct()
null,
1
);

foreach (self::getProviders() as $provider) {
add_privs('plugin_prefs.' . $plugin . '_' . $provider, self::getPrivs());

register_callback(
'Oui\Player\Admin::optionsLink',
'plugin_prefs.' . $plugin . '_' . $provider,
null,
1
);
}
}

/**
Expand All @@ -83,7 +94,20 @@ public function __construct()

public static function setProviders()
{
static::$providers = callback_event(self::getPlugin(), 'plug_providers', 0, array());
$providers = array();

$namespace = __NAMESPACE__ . "\\";

foreach(get_declared_classes() as $name) {
if(strpos($name, $namespace) === 0) {
$providers[] = strtolower(substr($name, strlen($namespace)));
}
}

static::$providers = array_merge(array_diff(
$providers,
array('admin', 'player', 'main', 'provider')
));
}

public function install()
Expand All @@ -107,7 +131,9 @@ public function uninstall()

public static function optionsLink()
{
header('Location: ?event=prefs#prefs_group_' . self::getPlugin());
global $event;

header('Location: ?event=' . str_replace('plugin_prefs.', 'prefs#prefs_group_', $event));
}

/**
Expand Down Expand Up @@ -255,7 +281,7 @@ public static function setAllPrefs()

// Adds a pref per provider to display/hide its own prefs group.
$options = array(
'default' => '0',
'default' => '1',
'valid' => array('0', '1'),
);
$options['group'] = $plugin;
Expand Down Expand Up @@ -356,15 +382,5 @@ private function deleteOldPrefs()

if (txpinterface === 'admin' && (in_array($event, array('plugin', 'prefs')) || substr($event, 0, strlen($pluginPrefs)) === $pluginPrefs)) {
new Admin;

$providers = Admin::getProviders();

if ($providers) {
foreach ($providers as $provider) {
if (in_array($event, array($pluginPrefs . '_' . lcfirst($provider), 'prefs'))) {
$provider::getInstance();
}
}
}
}
}
7 changes: 7 additions & 0 deletions src/Player.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ class Player
'wraptag' => array(
'default' => '',
),
'responsive' => array(
'default' => '',
),
),
'oui_if_player' => array(
'play' => array(
Expand Down Expand Up @@ -107,6 +110,10 @@ class Player
'provider' => array(
'default' => '',
),
'responsive' => array(
'default' => 'true',
'valid' => array('true', 'false'),
),
'providers' => array(
'default' => '',
),
Expand Down
Loading

0 comments on commit 2b110d4

Please sign in to comment.