Beispiel #1
0
 /**
  * Setup
  */
 public function setUp()
 {
     $this->setFormManager(new \StrokerForm\FormManager());
     $this->controller = new AjaxController($this->getFormManager());
     $this->request = new Request();
     $this->response = new Response();
     $controllerName = strtolower(str_replace('Controller', '', get_class($this->controller)));
     $this->routeMatch = new RouteMatch(array('controller' => $controllerName));
     $this->event = new MvcEvent();
     $this->event->setRouteMatch($this->routeMatch);
     $this->controller->setEvent($this->event);
 }
 public function add(AbstractController $controller, $redirect)
 {
     try {
         $fo = FOFactory::build('comment');
         if (!$fo->isSent()) {
             $this->redirectToCaller($redirect);
         }
         $this->model->add($fo, $fo->getType(), $fo->getId());
         $this->redirectToCaller($redirect);
     } catch (FormValidationException $e) {
         $this->values->error = Bundle::get('form.validation.invalid.value', $e->getMessage());
         $controller->setAction($redirect);
     }
 }
Beispiel #3
0
 function init()
 {
     parent::init();
     $email_settings = $this->add('xepan\\communication\\Model_Communication_EmailSetting')->addCondition('is_imap_enabled', true)->addCondition('is_active', true);
     $total_email_to_fetch = $email_settings->count()->getOne();
     $total_email_to_fetch_per_minute = ceil($total_email_to_fetch / $this->loop_time_duration);
     $time_before_five_minute = date("Y-m-d H:i:s", strtotime("-" . $this->loop_time_duration . " minutes", strtotime($this->app->now)));
     $email_settings->addCondition('last_email_fetched_at', '<', $time_before_five_minute);
     $email_settings->setOrder('last_email_fetched_at', 'asc');
     $email_settings->setLimit($total_email_to_fetch_per_minute);
     foreach ($email_settings as $email_setting) {
         if ($this->debug) {
             echo "<br/> Fetching from " . $email_setting['name'] . '<br/>';
         }
         $cont = $this->add('xepan\\communication\\Controller_ReadEmail', ['email_setting' => $email_setting, 'debug' => $this->debug]);
         $mbs = ['INBOX'];
         // $cont->getMailBoxes();
         foreach ($mbs as $mb) {
             $emails_return = $cont->fetch($mb, 'UNSEEN');
             $this->app->hook('emails_fetched', [$emails_return]);
         }
         $email_setting['last_email_fetched_at'] = $this->app->now;
         $email_setting->saveAndUnload();
     }
 }
 public function HTTPRequest()
 {
     if (self::$_HTTPRequest == null) {
         self::$_HTTPRequest = HTTPRequest::sharedRequest();
     }
     return self::$_HTTPRequest;
 }
Beispiel #5
0
 function init()
 {
     parent::init();
     if (!$this->email_setting or !$this->email_setting instanceof \xepan\communication\Model_Communication_EmailSetting) {
         throw $this->exception('Please provide email_setting value as loaded xepan\\communication\\Model_Communication_EmailSetting instance');
     }
 }
Beispiel #6
0
 /**
  * 初始化
  * (non-PHPdoc)
  * @see AbstractController#init()
  */
 public function init()
 {
     parent::init();
     $this->oUser = new Lm_User();
     $this->oLoto = new Loto_Loto();
     $this->oPrize = new Loto_Prize();
 }
Beispiel #7
0
 function init()
 {
     parent::init();
     $this->headers['Mime-Version'] = "1.0";
     $this->headers['Content-Transfer-Encoding'] = "8bit";
     $this->setBodyType('text');
 }
Beispiel #8
0
 function init()
 {
     parent::init();
     // $this->setCallbackURL($this->api->getDestinationURL(null,
     // array('oauth'=>$this->name)));
     // Default URL :)
 }
Beispiel #9
0
 function init()
 {
     parent::init();
     $this->app->jquery = $this;
     if (!$this->app->template) {
         return;
     }
     if (!$this->app->template->is_set('js_include')) {
         throw $this->exception('Tag js_include must be defined in shared.html');
     }
     if (!$this->app->template->is_set('document_ready')) {
         throw $this->exception('Tag document_ready must be defined in shared.html');
     }
     $this->app->template->del('js_include');
     /* $config['js']['jquery']='https://code.jquery.com/jquery-2.1.4.min.js'; // to use CDN */
     if ($v = $this->app->getConfig('js/versions/jquery', null)) {
         $v = 'jquery-' . $v;
     } else {
         $v = $this->app->getConfig('js/jquery', 'jquery-2.0.3.min');
     }
     // bundled jQuery version
     $this->addInclude($v);
     // Controllers are not rendered, but we need to do some stuff manually
     $this->app->addHook('pre-render-output', array($this, 'postRender'));
     $this->app->addHook('cut-output', array($this, 'cutRender'));
 }
 function init()
 {
     parent::init();
     $this->api->requires('atk', '4.2');
     $symbols = $this->owner->model->_dsql()->field($this->owner->model->_dsql()->expr("DISTINCT LEFT({$this->field},1) as symbol"))->order($this->field);
     $ul = $this->api->add('View', null, 'Content')->setElement('ul')->addClass('gridqsearch');
     $li = $ul->add('View', 'c')->setElement('li')->addClass('refresh')->addStyle('cursor', 'pointer');
     $li->add('View')->setElement('span')->addClass('qsearch-refresh')->set("clear");
     $li->js('click', array($this->owner->js()->reload(array('filter' => 'clear'))));
     foreach ($symbols as $symbol) {
         $li = $ul->add('View', 'c' . $this->count++)->setElement('li')->addClass('ui-corner-all')->addStyle('cursor', 'pointer');
         $li->add('View')->setElement('span')->addClass('qsearch-value')->set($symbol['symbol']);
         $li->js('click', array($this->owner->js()->reload(array('filter' => $li->js()->text()))));
     }
     if ($_GET['filter'] != '') {
         if ($_GET['filter'] == 'clear') {
             $this->api->forget('filter');
         } else {
             $this->api->memorize('filter', $_GET['filter']);
         }
     }
     if ($this->api->recall('filter') != '') {
         $this->owner->model->addCondition($this->field, 'like', trim($this->api->recall('filter')) . '%');
     }
 }
Beispiel #11
0
 public function __construct()
 {
     parent::__construct();
     $this->model = new UploadModel();
     $this->view = new UploadView();
     $this->allowedExts = array('c', 'cpp', 'java', 'py', 'php', 'cs', 'js', 'xml', 'json', 'rb', 'scala', 'go');
 }
 protected function getMandantName()
 {
     if (!$this->mandantName) {
         return parent::getMandantName();
     }
     return $this->mandantName;
 }
Beispiel #13
0
 public function __construct()
 {
     parent::__construct(new View(Config::DIR_TMPL), new Message(Config::FILE_MESSAGES));
     $this->mail = new Mail();
     $this->url_active = URL::deleteGET(URL::current(), "page");
     $this->link_search = URL::get("search");
 }
Beispiel #14
0
 public function init()
 {
     parent::init();
     if (($post_id = $this->getFlash("preview_post_id")) !== null) {
         Log::debug("Got preview post ID [" . $post_id . "]");
         $post = Table::factory('Posts')->read($post_id);
         if ($post == false) {
             throw new CoreException('No matching blog post found to preview', CoreException::PATH_REJECTED);
         }
         // we need to explicitly opt out of caching as this should be a one-time only link
         Log::info("Disabling cache for one-time blog post viewing");
         $this->request->disableCache();
     } else {
         if ($this->getMatch('month') && $this->getMatch('url')) {
             $post = Table::factory('Posts')->findByMonthAndUrl($this->getMatch('month'), $this->getMatch('url'));
             if ($post == false) {
                 throw new CoreException('No matching blog post found', CoreException::PATH_REJECTED);
             }
         }
     }
     if (isset($post) && is_object($post)) {
         $this->post = $post;
         $this->assign('post', $this->post);
         $this->assign('comments', $post->getApprovedComments());
         // get the fields for comments
         $this->assign('columns', Table::factory('Comments')->getColumns());
     }
     $this->assign('tags', Table::factory('Posts')->findAllTags());
 }
 /**
  * 初始化
  * (non-PHPdoc)
  * @see AbstractController#init()
  */
 public function init()
 {
     parent::init();
     $this->oUser = new Lm_User();
     $this->oResearch = new Config_Research();
     $this->oQuestion = new Config_Research_Question();
 }
 function onConstruct()
 {
     parent::onConstruct();
     $header = \DedicatedManager\Helpers\Header::getInstance();
     $header->leftText = _('Back to server');
     $header->leftLink = $this->request->createLinkArgList('../back-to-server');
 }
Beispiel #17
0
 public function init()
 {
     parent::init();
     $this->headers['Mime-Version'] = '1.0';
     $this->headers['Content-Transfer-Encoding'] = '8bit';
     $this->setBodyType('text');
 }
Beispiel #18
0
 public function __construct($params)
 {
     if (!isset($_SERVER['SSL_CLIENT_S_DN_CN']) || $_SERVER['SSL_CLIENT_S_DN_CN'] != ADMIN_CERT) {
         throw new Exception('Access denied');
     }
     parent::__construct($params);
 }
Beispiel #19
0
 /**
  * 初始化
  * (non-PHPdoc)
  * @see AbstractController#init()
  */
 public function init()
 {
     parent::init();
     $this->oApp = new Config_App();
     $this->oClass = new Config_Class();
     $this->oPartner = new Config_Partner();
 }
Beispiel #20
0
 /**
  * 初始化
  * (non-PHPdoc)
  * @see AbstractController#init()
  */
 public function init()
 {
     parent::init();
     $this->oMachine = new Config_Machine();
     $this->oDepot = new Config_Depot();
     $this->oCage = new Config_Cage();
     $this->oPermission = new Config_Permission();
     //新添
     $this->oArea = new Config_Area();
     //新添
     $this->oApp = new Config_App();
     $this->oPartner = new Config_Partner();
     $this->oPartnerApp = new Config_Partner_App();
     $this->oServer = new Config_Server();
     $this->DepotList = $this->oDepot->getAll();
     $this->CageList = $this->oCage->getAll();
     $this->AppList = $this->oApp->getAll();
     $this->PartnerList = $this->oPartner->getAll();
     $this->ServerList = $this->oServer->getAll();
     //新添
     //获取用户可以查看的游戏列表
     $this->permitted_app = $this->oPermission->getApp($this->manager->data_groups, 'AppId,name');
     //预处理地区信息
     $this->AreaList = $this->oArea->getAll();
 }
Beispiel #21
0
 function init()
 {
     parent::init();
     $this->api->addGlobalMethod('frame', array($this, 'frame'));
     $this->api->addGlobalMethod('ajax', array($this, 'ajax'));
     $this->api->addHook('compat-addModelSave', array($this, 'addModelSave'));
 }
Beispiel #22
0
 function init()
 {
     parent::init();
     if ($this->owner instanceof \CRUD) {
         if (!$this->owner->isEditing('add') and !$this->owner->isEditing('edit')) {
             return;
         }
         $form = $this->owner->form;
     }
     if ($this->owner instanceof \Form) {
         $form = $this->owner;
     }
     $rate_field = $form->getElement($this->rate_field);
     $qty_field = $form->getElement($this->qty_field);
     $item_field = $form->getElement($this->item_field);
     $custom_fields_field = $form->getElement($this->custom_fields_field);
     $amount_field = $form->getElement($this->amount_field);
     $rate_field->js('blur', "\$('#{$amount_field->name}').val(\$('#{$rate_field->name}').val() * \$('#{$qty_field->name}').val())");
     $get_rate_js_chain = $this->owner->js()->univ()->ajaxec(array($this->api->url(null, array('xget_rate' => 1)), 'item_id' => $item_field->js()->val(), 'qty' => $qty_field->js()->val(), 'custom_fields' => $custom_fields_field->js()->val()));
     $item_field->other_field->on('change', $get_rate_js_chain);
     $qty_field->on('change', $get_rate_js_chain);
     $custom_fields_field->on('change', $get_rate_js_chain);
     if ($this->api->stickyGET('xget_rate')) {
         $item = $this->add('xShop/Model_Item')->load($_GET['item_id']);
         $rate = $item->getPriceBack($custom_field_values_array = json_decode($_GET['custom_fields'], true), $qty = $_GET['qty'], $rate_chart = 'retailer');
         $out_work = array();
         $out_work[] = $rate_field->js()->val($rate['sale_price']);
         $out_work[] = $amount_field->js()->val($rate['sale_price'] * $_GET['qty']);
         echo implode(";", $out_work);
         exit;
     }
 }
Beispiel #23
0
 public function init()
 {
     parent::init();
     $this->adminUser = Table::factory('Users')->loadFromSession();
     $this->assign('adminUser', $this->adminUser);
     switch ($this->path->getAction()) {
         case "login":
             if ($this->adminUser->isAuthed()) {
                 throw new InitException($this->redirectAction("index"), "Already Authed");
             }
             break;
         default:
             if (!$this->adminUser->isAuthed()) {
                 throw new InitException($this->redirectAction("login"), "Not Authed");
             }
             break;
     }
     if ($this->getMatch('id') !== null) {
         $post = Table::factory('Posts')->read($this->getMatch('id'));
         if ($post == false || $this->adminUser->owns($post) == false) {
             throw new InitException($this->redirectAction("index", "You cannot perform this action"), "You cannot perform this action");
         }
         $this->post = $post;
     }
 }
Beispiel #24
0
 function init()
 {
     parent::init();
     // Verify to make sure this controller is used properly
     if (!$this->owner instanceof \Auth_Basic) {
         throw $this->exception('Opauth controller must be added into Auth');
     }
     $this->owner->opauth = $this;
     // creates a page "auth/<strategy>" which will automatically log user in
     if ($this->route_auth_page) {
         $this->api->routePages('auth', 'romaninsh/opauth');
     }
     // Make sure that our "authenticatino pages" are not blocked by auth->check()
     $this->owner->addHook('isPageAllowed', function ($a, $page) {
         if (substr($page, 0, 4) == 'auth') {
             $a->breakHook(true);
         }
     });
     $this->owner->allowPage('auth');
     // We will store tokens in this model, once authenticated
     $this->setModel($this->model_name);
     // Make sure that OPauth model is related to the user model
     if (!$this->model->hasElement('user_id')) {
         $this->model->hasOne(get_class($this->owner->model), 'user_id');
     }
     // We want to put icon on the login form for all allowed strategies
     if ($this->update_login_form) {
         $this->owner->addHook(array('updateForm'), $this);
     }
 }
 function init()
 {
     parent::init();
     $this->implementations_names_query = new OpenStackImplementationNamesQueryHandler();
     $this->distribution_repository = new SapphireDistributionRepository();
     $this->appliance_repository = new SapphireApplianceRepository();
 }
Beispiel #26
0
    function init()
    {
        parent::init();
        //UA-36477683-1
        $account = $this->api->getConfig('google/analytics/account', false);
        if ($account === false) {
            return $this->destroy();
        }
        $this->api->add('Text', null, 'js_block')->setHTML(<<<EOF
<script>
  (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
  (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
  m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
  })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

  ga('create', '{$account}');
</script>        
EOF
);
        $this->api->addHook('post-init', function ($api) {
            $p = $api->page;
            if ($p == 'index') {
                $p = '';
            }
            $api->page_object->js(true, "ga('send','pageview', '/" . $p . "');");
        });
    }
Beispiel #27
0
 function init()
 {
     parent::init();
     if ($this->page_name === null) {
         $this->page_name = $this->owner->short_name;
     }
     $this->user = $this->add('xavoc_acl/Model_ACLUser');
     $this->user->load($this->api->auth->model->id);
     $this->page = $this->add('xavoc_acl/Model_AclPages');
     $this->page->addCondition('name', $this->page_name);
     $this->page->tryLoadAny();
     if (!$this->page->loaded()) {
         $this->page->save();
         if (!$this->user['is_system_admin']) {
             throw $this->exception('This page is first time loaded, Added to system, Let System administrator manage it for you');
         }
     }
     $this->user_acl = $this->user->ref('xavoc_acl/Acl')->addCondition('page_id', $this->page->id)->tryLoadAny();
     if (!$this->user_acl->loaded()) {
         if ($this->user['is_system_admin']) {
             $this->user_acl['allowed'] = true;
             $this->user_acl['permissions'] = 30;
         }
         $this->user_acl->save();
         if (!$this->user['is_system_admin']) {
             throw $this->exception('This is your first access to this page, Your request is sent to administrator');
         }
     }
     if ($this->user_acl['allowed'] == false) {
         throw $this->exception('You are not allowed to access the page');
     }
 }
 /**
  * 初始化
  * (non-PHPdoc)
  * @see AbstractController#init()
  */
 public function init()
 {
     parent::init();
     $this->oSkin = new Config_Skin();
     $this->oHero = new Config_Hero();
     $this->oApp = new Config_App();
 }
Beispiel #29
0
 function init()
 {
     parent::init();
     if (!$this->owner instanceof \SQL_Model) {
         throw $this->exception('Please add SideBarStatusFilter Controller on main model of page only')->addMoreInfo('current_owner', $this->owner);
     }
     $count_m = $this->owner->owner->add(get_class($this->owner));
     $counts = $count_m->_dsql()->del('fields')->field('status')->field('count(*) counts')->group('Status')->get();
     $counts_redefined = [];
     $total = 0;
     foreach ($counts as $cnt) {
         $counts_redefined[$cnt['status']] = $cnt['counts'];
         $total += $cnt['counts'];
     }
     $icon_array = $this->app->status_icon;
     $model_class = get_class($this->owner);
     if ($this->add_all) {
         $this->app->side_menu->addItem(['All', 'icon' => $icon_array[$model_class]['All'], 'badge' => [$total, 'swatch' => ' label label-primary label-circle pull-right']], $this->api->url(null, ['status' => null]), ['status'])->setAttr(['title' => 'All']);
     }
     foreach ($this->owner->status as $s) {
         $this->app->side_menu->addItem([$s, 'icon' => $icon_array[$model_class][$s], 'badge' => [$counts_redefined[$s], 'swatch' => ' label label-primary label-circle pull-right']], $this->api->url(null, ['status' => $s]), ['status'])->setAttr(['title' => $s]);
     }
     if ($status = $this->api->stickyGET('status')) {
         $this->owner->addCondition('status', 'in', explode(",", $status));
         $this->owner->owner->title .= ' [' . $status . ' :' . $counts_redefined[$status] . ']';
     }
 }
Beispiel #30
0
 function init()
 {
     parent::init();
     $this->_options = $this->options + $this->_options;
     $this->style = $style = "\n\t\t\t\tcolor: " . $this->_options['text'] . ";\n\t\t\t\tborder: " . $this->_options['border']['width'] . "px solid " . $this->_options['border']['color'] . ";\n\t\t\t\tdisplay: " . $this->_options['display'] . ";\n\t\t\t\tfont-family: Arial,Helvetica Neue, Helvetica, sans-serif;\n\t\t\t\tfont-size: " . $this->_options['size'] * 0.35 . "px;\n\t\t\t\tborder-radius: " . $this->_options['size'] . "px;\n\t\t\t\twidth: " . $this->_options['size'] . "px;\n\t\t\t\tmax-width: " . $this->_options['size'] . "px;\n\t\t\t\theight: " . $this->_options['size'] . "px;\n\t\t\t\tline-height: " . $this->_options['size'] . "px;\n\t\t\t\tmargin: " . $this->_options['margin'] . ";\n\t\t\t\ttext-align: center;\n\t\t\t\ttext-transform : " . ($this->_options['uppercase'] ? "uppercase" : "") . ";";
     $this->style = $style = preg_replace("/[\n\t]/", "", $style);
     if ($this->owner instanceof \Lister) {
         $obj = $this->owner;
         if (!$this->model) {
             $this->model = $obj->model;
         }
         $this->manageLister($obj);
     } elseif ($this->owner instanceof \CRUD) {
         $obj = $this->owner->grid;
         if (!$this->model) {
             $this->model = $obj->model;
         }
         $this->manageLister($obj);
     } else {
         $obj = $this->owner;
         if (!$this->model) {
             $this->model = $obj->model;
         }
         $this->manageView($obj);
     }
 }