public function testGeneratedHtml()
    {
        $settings_page = new SettingsPage(array("app_id" => "foo", "secret" => "bar"));
        $expectedHtml = <<<END
<h1>Intercom Settings</h1>

<div id="intercom-settings-container" class="postbox-container">
  <form method="post" action="">
    <table class="form-table">
      <tbody>
        <tr>
          <td><b>App ID</b></td>
          <td><input name="intercom[app_id]" type="text" value="foo" placeholder="App ID"></td>
        </tr>
        <tr>
          <td><b>Secret</b></td>
          <td><input name="intercom[secret]" type="text" value="bar" placeholder="Secret"></td>
        </tr>
      </tbody>
    </table>
    <input name="intercom-submit" type="submit" value="Save">
  </form>
</div>
END;
        $this->assertEquals($expectedHtml, $settings_page->html());
    }
Esempio n. 2
0
 public static function getInstance($path, $params)
 {
     if (!count($path)) {
         self::redirectTo('home');
         exit;
     }
     $pname = $path[0];
     $path = self::nextPath($path);
     switch ($pname) {
         case 'home':
             $page = HomePage::getInstance($path, $params);
             break;
         case 'register':
             $page = RegistrationPage::getInstance($path, $params);
             break;
         case 'login':
             $page = LoginPage::getInstance($path, $params);
             break;
         case 'logout':
             $page = LogoutPage::getInstance($path, $params);
             break;
         case 'switch-user':
             $page = SwitchUserPage::getInstance($path, $params);
             break;
         case 'links':
             $page = LinksPage::getInstance($path, $params);
             break;
         case 'users':
             $page = UsersPage::getInstance($path, $params);
             break;
         case 'groups':
             $page = GroupsPage::getInstance($path, $params);
             break;
         case 'settings':
             $page = SettingsPage::getInstance($path, $params);
             break;
         case 'tools':
             $page = ToolsPage::getInstance($path, $params);
             break;
         case 'installation':
             $page = InstallationPage::getInstance($path, $params);
             break;
         default:
             $page = NotFoundPage::getInstance($path, $params);
     }
     return $page;
 }
Esempio n. 3
0
function render_options_page()
{
    if (!current_user_can('manage_options')) {
        wp_die('You do not have sufficient permissions to access Intercom settings');
    }
    $options = get_option('intercom');
    $settings_page = new SettingsPage(array("app_id" => $options['app_id'], "secret" => $options['secret'], "enableChat" => isset($options['enableChat']) ? $options['enableChat'] : 'false'));
    echo $settings_page->htmlUnclosed();
    wp_nonce_field('intercom-update');
    echo $settings_page->htmlClosed();
}
Esempio n. 4
0
 /**
  * Lists all models.
  */
 public function actionIndex()
 {
     $this->hasPrivilege(Acl::ACTION_VIEW);
     $this->pageTitle = Lang::t($this->resourceLabel . 's');
     $this->showPageTitle = TRUE;
     $this->render('index', array('model' => SettingsPage::model()->searchModel(array(), $this->settings[Constants::KEY_PAGINATION])));
 }
Esempio n. 5
0
 /**
  * creates and builds admin interface for a settings page.
  * @param type $config
  * @param type $method
  */
 public function addSettingsPage($config, $method = self::FROM_FILE)
 {
     $configData = self::getConfigObject($config, $method);
     SettingsPage::createFromConfig($configData, $this->templateHandler);
 }