From fcdd844de48998cd50bfdcaa6c3314ad8219e957 Mon Sep 17 00:00:00 2001 From: Kienan Stewart Date: Sat, 17 Feb 2018 09:34:29 -0500 Subject: [PATCH] Add hook_oci_menu to allow other classes to add new items to the OCI menu --- src/class/m_oci.php | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/class/m_oci.php b/src/class/m_oci.php index a50aaf8..a480b9f 100644 --- a/src/class/m_oci.php +++ b/src/class/m_oci.php @@ -21,7 +21,7 @@ class m_oci { function hook_menu() { - global $hooks, $L_ALTERNC_WPCLI_BIN, $L_ALTERNC_DRUSH_BIN; + global $hooks; $menu = array( 'title' => _('Quick Install'), 'ico' => 'images/ocilogo.png', @@ -29,27 +29,35 @@ class m_oci { 'pos' => 11, 'links' => array(), ); - // @TODO invoke a hook to get supported applications - // need: id (eg. wordpress), weight (to order), ico, and - // optionally - a different action path. - // @TODO required binaries for installation: eg, wp-cli, drush + $links = $hooks->invokve('hook_oci_menu'); + if ($links) { + $menu['links'] = $links; + } + if ($menu['links']) { + return $menu; + } + } + + /** + * Implements hook_oci_menu(). + */ + function hook_oci_menu() { + $links = array(); if ($this->app_is_installable('wordpress')) { - $menu['links'][] = array( + $links[] = array( 'txt' => _('WordPress'), 'url' => 'oci_install.php?app=wordpress', 'ico' => 'images/wordpress.png', ); } if ($this->app_is_installable('drupal')) { - $menu['links'][] = array( + $links[] = array( 'txt' => _('Drupal'), 'url' => 'oci_install.php?app=drupal', 'ico' => 'images/drupal.png', ); } - if ($menu['links']) { - return $menu; - } + return $links; } /**