本文整理汇总了PHP中AbstractController::init方法的典型用法代码示例。如果您正苦于以下问题:PHP AbstractController::init方法的具体用法?PHP AbstractController::init怎么用?PHP AbstractController::init使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类AbstractController
的用法示例。
在下文中一共展示了AbstractController::init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
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 . "');");
});
}
示例2: init
/**
* 初始化
* (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();
}
示例3: init
function init()
{
parent::init();
$this->implementations_names_query = new OpenStackImplementationNamesQueryHandler();
$this->distribution_repository = new SapphireDistributionRepository();
$this->appliance_repository = new SapphireApplianceRepository();
}
示例4: init
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');
}
}
示例5: init
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'));
}
示例6: init
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;
}
}
示例7: init
/**
* 初始化
* (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();
}
示例8: init
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')) . '%');
}
}
示例9: init
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;
}
示例10: init
public function init()
{
parent::init();
$this->headers['Mime-Version'] = '1.0';
$this->headers['Content-Transfer-Encoding'] = '8bit';
$this->setBodyType('text');
}
示例11: init
function init()
{
parent::init();
$this->api->pr = $this;
$this->profstart = time() + microtime();
$this->start('everything else');
}
示例12: init
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);
}
}
示例13: init
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', '');
}
示例14: init
function init()
{
parent::init();
$this->owner->addField('id')->type('int')->system(true);
$this->owner->addField('name');
$this->owner->addMethod('getBy,loadBy', $this);
}
示例15: init
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());
}