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(); } }