Example #1
0
 public function savesettingsAjaxAction(\Difra\Param\AjaxString $consumerKey, \Difra\Param\AjaxString $consumerSecret, \Difra\Param\AjaxString $oauthToken, \Difra\Param\AjaxString $oauthSecret, \Difra\Param\AjaxCheckbox $postToTwitter)
 {
     $oAuthArray = ['consumerKey' => $consumerKey->val(), 'consumerSecret' => $consumerSecret->val(), 'accessToken' => $oauthToken->val(), 'accessTokenSecret' => $oauthSecret->val(), 'postToTwitter' => $postToTwitter->val()];
     \Difra\Config::getInstance()->set('oAuth', $oAuthArray);
     \Difra\Ajaxer::refresh();
     \Difra\Ajaxer::notify(\Difra\Locales::getInstance()->getXPath('twitter/adm/oAuth/settingsSaved'));
 }
Example #2
0
 /**
  * Disable plugin
  *
  * @param \Difra\Param\AnyString $name
  */
 public function disableAjaxAction(\Difra\Param\AnyString $name)
 {
     if (!\Difra\Plugger::turnOff($name->val())) {
         \Difra\Ajaxer::notify(\Difra\Locales::get('adm/plugins/failed'));
     }
     \Difra\Ajaxer::refresh();
 }
Example #3
0
 /**
  * Alter table for Unify object
  *
  * @param \Difra\Param\AnyString $name
  */
 public function alterAjaxAction(\Difra\Param\AnyString $name)
 {
     try {
         /** @var \Difra\Unify\Item $class */
         $class = \Difra\Unify\Storage::getClass($name->val());
         $status = $class::getObjDbStatus();
         if ($status['status'] == 'alter') {
             \Difra\MySQL::getInstance()->query($status['sql']);
         }
     } catch (\Difra\Exception $ex) {
         \Difra\Ajaxer::notify($ex->getMessage());
     }
     \Difra\Ajaxer::refresh();
 }
Example #4
0
 /**
  * @backupGlobals enabled
  */
 public function test_actions()
 {
     \Difra\Debugger::disable();
     \Difra\Ajaxer::clean();
     $actions = [];
     \Difra\Ajaxer::notify('notification message');
     $actions[] = ['action' => 'notify', 'message' => 'notification message', 'lang' => ['close' => \Difra\Locales::get('notifications/close')]];
     \Difra\Ajaxer::display('<span>test</span>');
     $actions[] = ['action' => 'display', 'html' => '<span>test</span>'];
     \Difra\Ajaxer::error('error message <span>test</span>');
     $actions[] = ['action' => 'error', 'message' => 'error message &lt;span&gt;test&lt;/span&gt;', 'lang' => ['close' => \Difra\Locales::get('notifications/close')]];
     \Difra\Ajaxer::required('element');
     $actions[] = ['action' => 'require', 'name' => 'element'];
     \Difra\Ajaxer::invalid('inv1');
     $actions[] = ['action' => 'invalid', 'name' => 'inv1'];
     \Difra\Ajaxer::invalid('inv2');
     $actions[] = ['action' => 'invalid', 'name' => 'inv2'];
     \Difra\Ajaxer::status('field1', 'bad value', 'problem');
     $actions[] = ['action' => 'status', 'name' => 'field1', 'message' => 'bad value', 'classname' => 'problem'];
     \Difra\Ajaxer::redirect('/some/page');
     $actions[] = ['action' => 'redirect', 'url' => '/some/page'];
     $_SERVER['HTTP_REFERER'] = '/current/page';
     \Difra\Ajaxer::refresh();
     $actions[] = ['action' => 'redirect', 'url' => '/current/page'];
     \Difra\Ajaxer::reload();
     $actions[] = ['action' => 'reload'];
     \Difra\Ajaxer::load('someid', 'some <b>content</b>');
     $actions[] = ['action' => 'load', 'target' => 'someid', 'html' => 'some <b>content</b>'];
     \Difra\Ajaxer::close();
     $actions[] = ['action' => 'close'];
     \Difra\Ajaxer::reset();
     $actions[] = ['action' => 'reset'];
     \Difra\Envi::setUri('/current/page');
     \Difra\Ajaxer::confirm('Are you sure?');
     $actions[] = ['action' => 'display', 'html' => '<form action="/current/page" class="ajaxer"><input type="hidden" name="confirm" value="1"/>' . '<div>Are you sure?</div>' . '<input type="submit" value="' . \Difra\Locales::get('ajaxer/confirm-yes') . '"/>' . '<input type="button" value="' . \Difra\Locales::get('ajaxer/confirm-no') . '" onclick="ajaxer.close(this)"/>' . '</form>'];
     $this->assertEquals(\Difra\Ajaxer::getResponse(), json_encode(['actions' => $actions], \Difra\Ajaxer::getJsonFlags()));
     \Difra\Ajaxer::clean();
     $this->assertEquals(\Difra\Ajaxer::getResponse(), '[]');
     $this->assertFalse(\Difra\Ajaxer::hasProblem());
     \Difra\Ajaxer::reload();
     \Difra\Ajaxer::clean(true);
     $this->assertEquals(\Difra\Ajaxer::getResponse(), '[]');
     $this->assertTrue(\Difra\Ajaxer::hasProblem());
 }
Example #5
0
 /**
  * Manual user activation
  * @param Param\AnyInt $id
  */
 public function activateAjaxAction(Param\AnyInt $id)
 {
     User::getById($id->val())->activateManual();
     Ajaxer::refresh();
 }
Example #6
0
 /**
  * Move menu element down
  * @param Difra\Param\AnyInt $id
  */
 public function downAjaxAction(\Difra\Param\AnyInt $id)
 {
     \Difra\Plugins\CMS\MenuItem::get($id->val())->moveDown();
     \Difra\Ajaxer::refresh();
 }
Example #7
0
 public function sortAjaxAction(\Difra\Param\AnyString $sort)
 {
     \Difra\Plugins\Catalog::getInstance()->setSort($sort->val());
     \Difra\Ajaxer::refresh();
 }
Example #8
0
 public function resetAjaxAction()
 {
     \Difra\Config::getInstance()->reset();
     \Difra\Ajaxer::notify(\Difra\Locales::get('adm/config/reset-done'));
     \Difra\Ajaxer::refresh();
 }