public function init() { // take the current extension path $dir = dirname(__FILE__); // generate alias name $alias = md5($dir); // create alias Yii::setPathOfAlias($alias, $dir); // import other classes Yii::import($alias . '.components.*'); if (isset($this->widgetId)) { $this->_widgetId = $this->widgetId; } else { $this->_widgetId = 'clonnable-fields-widget-' . $this->getId(true); } $fieldNum = 1; foreach ($this->fields as &$field) { if (!isset($field['field']['fieldClassName']) || !is_string($field['field']['fieldClassName']) || $field['field']['fieldClassName'] == '') { $field['field']['fieldClassName'] = 'clonnable-field-' . $fieldNum; } $fieldNum++; } if ($this->minCloneRows > $this->startRows) { $this->startRows = $this->minCloneRows; } parent::init(); }
public function run() { if (empty($this->config['action'])) { throw new CException('EAjaxUpload: param "action" cannot be empty.'); } if (empty($this->config['allowedExtensions'])) { throw new CException('EAjaxUpload: param "allowedExtensions" cannot be empty.'); } if (empty($this->config['sizeLimit'])) { throw new CException('EAjaxUpload: param "sizeLimit" cannot be empty.'); } unset($this->config['element']); echo '<div id="' . $this->id . '"><noscript><p>Please enable JavaScript to use file uploader.</p></noscript></div>'; //$assets = dirname(__FILE__).'/assets'; //$baseUrl = Yii::app()->assetManager->publish($assets); //Yii::app()->clientScript->registerScriptFile($baseUrl . '/fileuploader.js', CClientScript::POS_HEAD); //$this->css=(!empty($this->css))?$this->css:$baseUrl.'/fileuploader.css'; //Yii::app()->clientScript->registerCssFile($this->css); $this->css = !empty($this->css) ? $this->css : 'fileuploader.css'; Yii::setPathOfAlias('ajaxupload', dirname(__FILE__)); $cs = Yii::app()->getClientScript(); $cs->packages['ajaxupload'] = array('basePath' => 'ajaxupload.assets', 'css' => array($this->css), 'js' => array('fileuploader.js')); $cs->registerPackage('ajaxupload'); $postParams = array('PHPSESSID' => session_id(), 'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken); if (isset($this->postParams)) { $postParams = array_merge($postParams, $this->postParams); } $config = array('button' => 'js:document.getElementById("' . $this->id . '")', 'debug' => false, 'multiple' => false); $config = array_merge($config, $this->config); $config['params'] = $postParams; $config = CJavaScript::encode($config); Yii::app()->getClientScript()->registerScript("FileUploader_" . $this->id, "var FileUploader_" . $this->id . " = new qq.FileUploaderBasic({$config}); ", CClientScript::POS_LOAD); }
/** * @return array list of all modules */ public function getModulePaths() { if ($this->_modulePaths === null) { $this->_modulePaths = array(); foreach (Yii::app()->modules as $module => $config) { if (is_array($config)) { $alias = 'application.modules.' . $module . '.' . ltrim($this->migrationSubPath, '.'); if (isset($config['class'])) { Yii::setPathOfAlias($alias, dirname(Yii::getPathOfAlias($config['class'])) . '/' . str_replace('.', '/', ltrim($this->migrationSubPath, '.'))); } elseif (isset($config['basePath'])) { Yii::setPathOfAlias($alias, $config['basePath'] . '/' . str_replace('.', '/', ltrim($this->migrationSubPath, '.'))); } $this->_modulePaths[$module] = $alias; $path = Yii::getPathOfAlias($alias); if ($path === false || !is_dir($path)) { $this->_disabledModules[] = $module; } } else { $this->_modulePaths[$config] = 'application.modules.' . $config . '.' . ltrim($this->migrationSubPath, '.'); } } } // add a pseudo-module 'core' $this->_modulePaths[$this->applicationModuleName] = $this->migrationPath; $path = Yii::getPathOfAlias($this->migrationPath); if ($path === false || !is_dir($path)) { $this->_disabledModules[] = $this->applicationModuleName; } return $this->_modulePaths; }
/** * Registers Analytics.js and initializes the tracking code */ public function init() { $sapi = php_sapi_name(); if ($sapi == 'cli') { return; } // Set the alias path if (Yii::getPathOfAlias('analytics') === false) { Yii::setPathOfAlias('analytics', realpath(dirname(__FILE__) . '/..')); } parent::init(); // Don't load up the analytics.js if we don't have any data $providers = $this->getProviders(); if (empty($providers)) { return; } // Conver options into json $json = CJSON::encode($providers); // Load up the asset manager $asset = Yii::app()->assetManager->publish(__DIR__ . DS . 'assets' . DS . 'js', true, -1, YII_DEBUG); $cs = Yii::app()->getClientScript(); // Register the appropriate script file $cs->registerScriptFile($asset . (YII_DEBUG ? '/analytics.js' : '/analytics.min.js')); // Initialize $cs->registerScript('analytics.js', "analytics.initialize({$json}); analytics.page();"); if ($this->lowerBounceRate) { $cs->registerScript('analytics.js-bounce-rate-15', 'setTimeout(function() { analytics.track("_trackEvent", "15 Seconds"); }, 15000 );'); $cs->registerScript('analytics.js-bounce-rate-30', 'setTimeout(function() { analytics.track("_trackEvent", "30 Seconds"); }, 30000 );'); $cs->registerScript('analytics.js-bounce-rate-60', 'setTimeout(function() { analytics.track("_trackEvent", "60 Seconds"); }, 60000 );'); } }
/** * Panel initialization. * Generate unique tag for page. Attach panels, log watcher. Register scripts for printing debug panel. */ public function init() { parent::init(); if (!$this->enabled) { return; } Yii::setPathOfAlias('yii2-debug', dirname(__FILE__)); Yii::app()->setImport(array('yii2-debug.*', 'yii2-debug.panels.*')); if ($this->logPath === null) { $this->logPath = Yii::app()->getRuntimePath() . '/debug'; } $panels = array(); foreach (CMap::mergeArray($this->corePanels(), $this->panels) as $id => $config) { if (!isset($config['highlightCode'])) { $config['highlightCode'] = $this->highlightCode; } $panels[$id] = Yii::createComponent($config, $this, $id); } $this->panels = $panels; Yii::app()->setModules(array($this->moduleId => array('class' => 'Yii2DebugModule', 'owner' => $this))); if ($this->internalUrls && Yii::app()->getUrlManager()->urlFormat == 'path') { $rules = array(); foreach ($this->coreUrlRules() as $key => $value) { $rules[$this->moduleId . '/' . $key] = $this->moduleId . '/' . $value; } Yii::app()->getUrlManager()->addRules($rules, false); } Yii::app()->attachEventHandler('onEndRequest', array($this, 'onEndRequest')); $this->initToolbar(); }
/** * Initializes the component. */ public function init() { // Register the bootstrap path alias. if (Yii::getPathOfAlias('bootstrap') === false) { Yii::setPathOfAlias('bootstrap', realpath(dirname(__FILE__) . '/..')); } // Prevents the extension from registering scripts and publishing assets when ran from the command line. if (Yii::app() instanceof CConsoleApplication) { return; } if ($this->coreCss !== false) { $this->registerCoreCss(); } if ($this->responsiveCss !== false) { $this->registerResponsiveCss(); } if ($this->yiiCss !== false) { $this->registerYiiCss(); } if ($this->jqueryCss !== false) { $this->registerJQueryCss(); } if ($this->enableJS !== false) { $this->registerCoreScripts(); } parent::init(); }
public function init() { $modules = glob(Yii::getPathOfAlias('application.modules') . '/*', GLOB_ONLYDIR); foreach ($modules as $dir) { Yii::setPathOfAlias(basename($dir), $dir); } if (isset($this->_domains[Yii::app()->request->serverName])) { $config = $this->_domains[Yii::app()->request->serverName]; if (is_string($config)) { $configFile = Yii::getPathOfAlias('application.config.domains.' . $config) . '.php'; if (is_file($configFile)) { $config = (include $configFile); } else { $config = array(); } } Yii::app()->configure($config); $this->loadDomain(); $domainTheme = Yii::app()->getParams()->offsetGet('theme'); if (!empty($domainTheme)) { Yii::app()->configure(array('theme' => $domainTheme)); } if (null !== Yii::app()->theme) { $config = Yii::app()->theme->basePath . DIRECTORY_SEPARATOR . 'views' . DIRECTORY_SEPARATOR . 'config.php'; if (is_file($config)) { $config = (include $config); Yii::app()->configure($config); } } } }
/** * Initializes the component. */ public function init() { // Register the bootstrap path alias. if (Yii::getPathOfAlias('bootstrap') === false) { Yii::setPathOfAlias('bootstrap', realpath(dirname(__FILE__) . '/..')); } }
public function init() { parent::init(); Yii::setPathOfAlias('PhpAmqpLib', Yii::getPathOfAlias('vendor.yiiext.AMQP.PhpAmqpLib')); $this->_connect = new PhpAmqpLib\Connection\AMQPConnection($this->host, $this->port, $this->login, $this->password, $this->vhost); $this->_channel = $this->_connect->channel(); }
/** * Initializes the admin module. */ public function init() { parent::init(); Yii::setPathOfAlias('admin', dirname(__FILE__)); Yii::app()->setComponents(array('errorHandler' => array('class' => 'CErrorHandler', 'errorAction' => $this->getId() . '/default/error'), 'user' => array('class' => 'WebUser', 'stateKeyPrefix' => 'admin', 'loginUrl' => Yii::app()->createUrl($this->getId() . '/default/login')), 'widgetFactory' => array('class' => 'CWidgetFactory', 'widgets' => array())), false); $this->setImport(array('admin.models.*', 'admin.components.*')); }
public function __construct($config = null) { if (is_string($config)) { $config = (require $config); } Yii::setApplication($this); //保存整个app实例 if (isset($config['basePath'])) { $this->setBasePath($config['basePath']); unset($config['basePath']); } else { $this->setBasePath('protected'); } //设置别名,后面就可以用application表示basePath了 Yii::setPathOfAlias('application', $this->getBasePath()); //钩子,模块 预 初始化时执行,子类实现。不过这时,配置还没有写入框架 $this->preinit(); $this->registerCoreComponents(); //父类实现 $this->configure($config); //加载静态应用组件 $this->preloadComponents(); //这才开始初始化模块 $this->init(); }
public function init() { $this->_params = isset(Yii::app()->params['migraptor']) && is_array(Yii::app()->params['migraptor']) ? Yii::app()->params['migraptor'] : []; $migrationsBasePath = realpath(isset($this->_params['base_path']) ? $this->_params['base_path'] : Yii::app()->basePath . '/../migraptor'); $this->_skipConnections = isset($this->_params['skip_connections']) ? $this->_params['skip_connections'] : []; if (!is_array($this->_skipConnections)) { $this->_skipConnections = [$this->_skipConnections]; } Yii::setPathOfAlias('migraptor', $migrationsBasePath); $this->_migrationsBasePath = 'migraptor'; $this->_projectMigrationTypes = isset($this->_params['migration_types']) && is_array($this->_params['migration_types']) ? $this->_params['migration_types'] : []; $this->_migrationTypes = $this->_defaultMigrationTypes; $migrationTypesDefault = array_combine($this->_migrationTypesDefault, $this->_migrationTypesDefault); foreach ($this->_projectMigrationTypes as $migrationTypeKey => $migrationType) { if (isset($this->_migrationTypes[$migrationTypeKey])) { $projectMigrationType = $this->_projectMigrationTypes[$migrationTypeKey]; if ($projectMigrationType === false) { unset($this->_migrationTypes[$migrationTypeKey]); unset($migrationTypesDefault[$migrationTypeKey]); continue; } } $this->_migrationTypes[$migrationTypeKey] = $migrationType; } $this->_migrationTypesDefault = $migrationTypesDefault; $this->isDone = false; register_shutdown_function([$this, 'onShutdown']); }
public function init() { Controller::initParams(); // this method is called when the module is being created // you may place code here to customize the module or the application Yii::app()->setComponent('bootstrap', array('class' => 'ext.bootstrap.components.Bootstrap', 'responsiveCss' => true)); Yii::setPathOfAlias('bootstrap', dirname(__FILE__) . DIRECTORY_SEPARATOR . '../../extensions/bootstrap'); Yii::app()->bootstrap->init(); // import the module-level models and components $this->setImport(array('admin.models.*', 'admin.components.*')); Yii::app()->setComponents(array('user' => array('class' => 'AdminUser', 'loginUrl' => Yii::app()->createAbsoluteUrl('admin/login'), 'allowAutoLogin' => true)), true); $this->layout = 'application.modules.admin.views.layouts.column1'; if (Yii::app()->params['STORE_OFFLINE'] == '-1') { die('Admin Panel unavailable due to account suspension.'); } if (isset($_POST['url']) && isset($_POST['password'])) { $model = new LoginForm(); if ($model->loginLightspeed($_POST['user'], $_POST['password'])) { Yii::app()->getRequest()->redirect(Yii::app()->createUrl("/admin")); } else { die("You have an invalid password set in your eCommerce options. Cannot continue."); } } if (!Yii::app()->user->isGuest) { if (Yii::app()->user->shouldLogOut()) { Yii::app()->user->logout(false); } } _xls_set_conf('ADMIN_PANEL', date("Y-m-d H:i:s")); parent::init(); }
function launch_codeception_yii_bridge() { Yii::setPathOfAlias('codeception-yii', __DIR__); Yii::import('codeception-yii.test.CTestCase'); Yii::import('codeception-yii.web.CodeceptionHttpRequest'); Yii::import('system.test.CDbTestCase'); Yii::import('system.test.CWebTestCase'); }
public function init() { parent::init(); $dir = dirname(__FILE__); $alias = md5($dir); Yii::setPathOfAlias($alias, $dir); Yii::import($alias . '.simple_image'); }
public function init() { if (Yii::getPathOfAlias('core') === false) { Yii::setPathOfAlias('core', realpath(dirname(__FILE__) . '/..')); } Yii::app()->setLanguage(strtolower(Yii::app()->getLanguage())); parent::init(); }
public function preinit() { $this->checkDependencies(); Yii::setPathOfAlias('bootstrap', 'protected/modules/admin/library/bootstrap'); // Reset the front-end's client script because we don't want // both front-end styles being applied in this module. Yii::app()->clientScript->reset(); }
public function init() { Yii::setPathOfAlias('Pheal', $this->pheal_class); Yii::import('Pheal'); $cfg = ["keyID" => isset($this->config['keyID']) ? $this->config['keyID'] : null, "vCode" => isset($this->config['vCode']) ? $this->config['vCode'] : null, "scope" => isset($this->config['scope']) ? $this->config['scope'] : "account"]; $this->config = $cfg; $this->_pheal = new \Pheal\Pheal($this->config['keyID'], $this->config['vCode'], $this->config['scope']); }
/** * init function */ public function init() { parent::init(); $dir = dirname(__FILE__); $alias = md5($dir); Yii::setPathOfAlias($alias, $dir); Yii::import($alias . '.LightOpenID'); }
public function init() { Yii::setPathOfAlias('disqusComments', dirname(__FILE__)); Yii::import('disqusComments.models.*'); Yii::import('disqusComments.helpers.*'); Yii::import('disqusComments.actions.*'); parent::init(); }
public function init() { Yii::app()->setViewPath(Yii::getPathOfAlias('application') . "/views-cities"); Yii::app()->setComponent('bootstrap', array('class' => 'ext.bootstrap.components.Bootstrap', 'responsiveCss' => true)); Yii::setPathOfAlias('bootstrap', dirname(__FILE__) . DIRECTORY_SEPARATOR . '../extensions/bootstrap'); Yii::app()->bootstrap->init(); set_time_limit(300); //We override init() to keep our system from trying to autoload stuff we haven't finished converting yet }
/** * Creates alias eauth and adds some import paths to simplify * class files lookup. */ public function init() { if (!Yii::getPathOfAlias('eauth')) { Yii::setPathOfAlias('eauth', dirname(__FILE__)); } Yii::import('eauth.*'); Yii::import('eauth.services.*'); Yii::import('eauth.custom_services.*'); }
public function init() { // Register the bootstrap path alias. if (!Yii::getPathOfAlias('notification')) { Yii::setPathOfAlias('notification', realpath(dirname(__FILE__))); } Yii::import('notification.*'); Yii::import('notification.type.*'); }
public function init() { $moduleDir = dirname(__FILE__); Yii::setPathOfAlias('pluginModule', $moduleDir); Yii::import('pluginModule.lib.*'); Yii::import('pluginModule.interface.*'); Yii::import('pluginModule.model.*'); require_once $moduleDir . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'PluginAbstract.php'; }
public function init() { // Add alias path Yii::setPathOfAlias('Doctrine', $this->getBasePath() . '/vendor/doctrine'); Yii::setPathOfAlias('Symfony', $this->getBasePath() . '/vendor/Symfony'); // Init DoctrineORM $this->initDoctrine(); parent::init(); }
/** * {@inheritDoc} * @see CModule::preinit() */ protected function preinit() { parent::preinit(); Yii::setPathOfAlias('pluggable', dirname(__DIR__)); // composer installation if (basename(dirname(dirname(dirname(__DIR__)))) === 'vendor') { Yii::setPathOfAlias('vendor', dirname(dirname(dirname(__DIR__)))); } }
public function init() { Yii::setPathOfAlias('hotelBooker', realpath(dirname(__FILE__))); Yii::import('common.extensions.payments.models.Bill'); Yii::import('hotelBooker.actions.*'); Yii::import('hotelBooker.models.*'); Yii::import('hotelBooker.*'); Yii::import('site.common.modules.hotel.models.*'); }
public function init() { //set a pathAlias for our extension. now, we can use it anywhere, not only in extensions folder Yii::setPathOfAlias('fbgallery', realpath(dirname(__FILE__))); //if is dynamic page, use it id as pid else we have a static page if (isset($_GET['id'])) { $this->pid = $_GET['id']; } //isn't a pid set by user or by dynamic page //we have a static page if (!$this->pid) { $this->staticPage = true; } //import general libraries Yii::import('fbgallery.libs.general.*'); //load settings $this->conf = new conf(); //if is static page we assign it a pid if isn't manually set if ($this->staticPage) { $this->setPid(); } //set if actuall page is album or collection $this->album = Album::model()->find(array('condition' => "pid='{$this->pid}'")); $this->collection = Collection::model()->find(array('condition' => "pid='{$this->pid}'")); //set author of this page, if exists if ($this->album || $this->collection) { $this->author = $this->album ? $this->album->author : $this->collection->author; } //set level access for user (0=visitor, 1=editor, 2=admin) //it is necessary to custom the way how users are identified in your system FBAccess::setLevelAccess(); //$this->levelAccess means we are minim an editor user. //if user is minimum an editor, import libraries for editor panel if ($this->levelAccess) { Yii::import('fbgallery.libs.editor.*'); } //if user is admin, import libraries for control panel. //Control panel isn't accessible for editors and visitors if ($this->levelAccess === 2) { Yii::import('fbgallery.libs.admin.*'); } //set languages $this->lang = new lang($this->conf); //set paths and urls used in gallery $this->path = new path($this->conf->gFolder . '/' . $this->pid . '/', $this->dirs, realpath(dirname(__FILE__) . '/assets')); $this->url = new url($this->conf->gFolder, $this->pid, $this->conf->cssTheme, realpath(dirname(__FILE__) . '/assets')); //setsForAlbum if ($this->album) { $this->imgsOrder = unserialize($this->album->imgsOrder); $this->imgsInfo = unserialize($this->album->imgsInfo); } //is this page using shop style? if ($this->conf->isShopStyle) { shop::specific(); } }
public function __construct($config = null) { parent::__construct($config); // Set webroot alias. Yii::setPathOfAlias('webroot', realpath(Yii::getPathOfAlias('application') . '/../')); // Load email settings. $email = (require Yii::app()->basePath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'email.php'); $this->config = array_merge($this->config, $email); // Now initialize the plugin manager }
public function init() { // Register the cii path alias. if (Yii::getPathOfAlias('cii') === false) { Yii::setPathOfAlias('cii', realpath(dirname(__FILE__) . '/..')); } Cii::loadUserInfo(); $this->registerJqueryCore(); parent::init(); }