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 . "');"); }); }
/** * 初始化 * (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(); }
function init() { parent::init(); $this->implementations_names_query = new OpenStackImplementationNamesQueryHandler(); $this->distribution_repository = new SapphireDistributionRepository(); $this->appliance_repository = new SapphireApplianceRepository(); }
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'); } }
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')); }
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; } }
/** * 初始化 * (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 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')) . '%'); } }
public function init() { parent::init(); $target = $this->HTTPRequest()->sharedRequest()->objectForKey("target"); switch ($this->getAction()) { case self::ACTION_READ: $model = ReadAction::alloc()->init(); $model->setTarget($target); echo $model->read()->asJSON(); break; case self::ACTION_READ_HEADERS: $model = ReadHeadersAction::alloc()->init(); $model->setTarget($target); echo $model->readHeaders()->asJSON(); break; case self::ACTION_SET: $model = SetAction::alloc()->init(); $model->setTarget($target); echo json_encode($model->set()); break; default: throw new Exception("Unknown action '" . $this->getAction() . "'", MFUnknownActionError); } return $this; }
public function init() { parent::init(); $this->headers['Mime-Version'] = '1.0'; $this->headers['Content-Transfer-Encoding'] = '8bit'; $this->setBodyType('text'); }
function init() { parent::init(); $this->api->pr = $this; $this->profstart = time() + microtime(); $this->start('everything else'); }
function init() { parent::init(); if (!$this->owner instanceof Model_Table) { throw $this->exception('Use with Model_Table only'); } $ni = clone $this->owner; $msg = ""; foreach ($this->unique_fields as $field => $value) { if (is_array($value)) { foreach ($value as $f => $v) { $ni->addCondition($f, $v); $msg .= " {$f} with {$v} value,"; } } else { $ni->addCondition($field, $value); $msg .= "{$field} with {$value} "; } if ($this->owner->loaded()) { $ni->addCondition('id', '<>', $this->owner->id); } $ni->tryLoadAny(); if ($ni->loaded()) { throw $this->exception("Already Existes with {$msg}"); } //->setField($field); } }
function init() { parent::init(); $this->dbh = new PDO($this->api->getConfig('pdo/dsn'), $this->api->getConfig('pdo/user', 'root'), $this->api->getConfig('pdo/password', 'root'), $this->api->getConfig('pdo/options', array(PDO::ATTR_PERSISTENT => true))); $this->dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); $this->table_prefix = $this->api->getConfig('pdo/table_prefix', ''); }
function init() { parent::init(); $this->owner->addField('id')->type('int')->system(true); $this->owner->addField('name'); $this->owner->addMethod('getBy,loadBy', $this); }
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()); }
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'); } }
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(); } }
/** * 初始化 * (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(); }
/** * 初始化 * (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(); }
function init() { parent::init(); // $this->setCallbackURL($this->api->getDestinationURL(null, // array('oauth'=>$this->name))); // Default URL :) }
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; } }
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(); // 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); } }
/** * 初始化 * (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(); }
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); } }
function init() { parent::init(); if ($this->app->getConfig('websocket-notifications', false)) { $this->server = $this->app->getConfig('websocket-server', null); } }
function init() { parent::init(); $this->headers['Mime-Version'] = "1.0"; $this->headers['Content-Transfer-Encoding'] = "8bit"; $this->setBodyType('text'); }
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] . ']'; } }
/** * 初始化 * (non-PHPdoc) * @see AbstractController#init() */ public function init() { parent::init(); $this->oCage = new Config_Cage(); $this->oDepot = new Config_Depot(); $this->oMachine = new Config_Machine(); $this->DepotList = $this->oDepot->getAll(); }
function init() { parent::init(); // require_once(getcwd().'/../vendor/xepan/marketing/lib/SocialPosters/Base/SocialActivity.php'); // require_once(getcwd().'/../vendor/xepan/marketing/lib/SocialPosters/Base/SocialConfig.php'); // require_once(getcwd().'/../vendor/xepan/marketing/lib/SocialPosters/Base/SocialPost.php'); // require_once(getcwd().'/../vendor/xepan/marketing/lib/SocialPosters/Base/SocialUsers.php'); }