Автор: Беляев Дмитрий (admin@cogear.ru)
Наследование: extends Object
Пример #1
0
 /**
  * Хук на включение шестерёнки
  *
  * @param Gear $Gear
  * @param Core_ArrayObject $result
  */
 public function hookGearEnable($Gear, $result)
 {
     if ($result->success) {
         $install_lang = $Gear->getDir() . DS . 'lang' . DS . $this->lang . EXT;
         if (file_exists($install_lang)) {
             $lang = new Config($install_lang);
             Lang::factory('index')->import($lang->toArray())->save();
         }
     }
 }
Пример #2
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if ($dsn = $this->get('database.dsn')) {
         $config = parse_url($dsn);
         if (isset($config['query'])) {
             parse_str($config['query'], $query);
             $config += $query;
         }
         if (!isset($config['host'])) {
             $config['host'] = 'localhost';
         }
         if (!isset($config['user'])) {
             $config['user'] = '******';
         }
         if (!isset($config['pass'])) {
             $config['pass'] = '';
         }
         if (!isset($config['prefix'])) {
             $config['prefix'] = $this->get('database.default_prefix', '');
         }
         $config['database'] = trim($config['path'], '/');
         $driver = 'Db_Driver_' . ucfirst($config['scheme']);
         if (!class_exists($driver)) {
             return Message::error(t('Database driver <b>%s</b> not found.', 'Database errors', ucfirst($config['scheme'])));
         }
         $this->driver = new $driver($config);
         $this->hook('done', array($this, 'showErrors'));
         $this->hook('debug', array($this, 'trace'));
         cogear()->db = $this->driver;
     } else {
         die('Couldn\'t connect to database.');
     }
 }
Пример #3
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if (Ajax::is()) {
         event('ajax.hashchange');
     }
 }
Пример #4
0
 /**
  * Constructor
  */
 public function __construct()
 {
     $this->locale = config('site.locale', 'en');
     $this->date_format = config('site.date_format', 'Y-m-d H:i');
     date_default_timezone_set(config('site.timezone', 'Europe/Moscow'));
     parent::__construct();
 }
Пример #5
0
 /**
  * Initialize
  */
 public function init()
 {
     parent::init();
     foreach (cogear()->gears as $gear) {
         if (is_array($gear->access)) {
             foreach ($gear->access as $rule => $rights) {
                 $name = $gear->gear . '.' . $rule;
                 // Array of user roles
                 if (is_array($rights)) {
                     if (in_array(role(), $rights)) {
                         $this->rights->{$name} = TRUE;
                     } else {
                         $this->rights->{$name} = FALSE;
                     }
                 } else {
                     if (is_string($rights)) {
                         $callback = new Callback(array($gear, $rights));
                         if ($callback->check()) {
                             $this->rights->{$name} = $callback;
                         }
                     } elseif (is_bool($rights)) {
                         $this->rights->{$name} = $rights;
                     }
                 }
             }
         }
     }
 }
Пример #6
0
 /**
  * Request
  */
 public function request()
 {
     parent::request();
     if (config('installed')) {
         redirect(l('/'));
     }
 }
Пример #7
0
 /**
  * Constructor
  *
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = $name;
     $path = Gear::preparePath($name, 'templates') . EXT;
     $this->path = $path;
     $this->getTemplate();
 }
Пример #8
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $this->get = new Core_ArrayObject($_GET);
     $this->post = new Core_ArrayObject($_POST);
     $this->cookies = new Core_ArrayObject($_COOKIE);
 }
Пример #9
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $cogear = getInstance();
     Form::$types['file'] = 'Upload_Ajax_Form_File';
     Form::$types['image'] = 'Upload_Ajax_Form_Image';
 }
Пример #10
0
 /**
  * Constructor
  */
 public function __contsruct()
 {
     parent::__construct();
     $cogear = getInstance();
     $this->mcrypt_cipher = $cogear->get('secure.mcrypt_cipher', MCRYPT_BLOWFISH);
     $this->mcrypt_mode = $cogear->get('secure.mcrypt_mode', MCRYPT_MODE_ECB);
 }
Пример #11
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if (access('Dev.*') && cogear()->config->development) {
         hook('done', array($this, 'finish'));
     }
 }
Пример #12
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     hook('form.page-createdit.init', array($this, 'extendPageForm'));
     hook('Pages.showPage.after', array($this, 'attachCommentsToPage'));
     hook('stack.Page.info', array($this, 'extendPageInfo'));
     allow_role(array('comments post'), 100);
 }
Пример #13
0
 /**
  * Инициализация
  */
 public function init()
 {
     $config = config('database');
     $db = Db::factory('system', $config);
     if ($db->connect()) {
         parent::init();
         $this->object($db);
     }
 }
Пример #14
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $cogear = getInstance();
     $this->api = new Loginza_API();
     hook('form.user-login.result.before', array($this, 'hookUserForm'));
     hook('form.user-register.result.before', array($this, 'hookUserForm'));
     hook('form.user-profile.init', array($this, 'hookUserProfile'));
 }
Пример #15
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $cogear = getInstance();
     $cogear->router->addRoute(':index', array($this, 'index'), TRUE);
     $url = config('pages.url', Pages_Gear::DEFAULT_PAGE_URL);
     $cogear->router->addRoute(str_replace(array('.', '<id>', '<url>'), array('\\.', '(?P<id>\\d+)', '.+'), $url), array($this, 'catchPage'), TRUE);
     allow_role(array('pages create'), 100);
 }
Пример #16
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if (!class_exists('ZipArchive')) {
         error(t('Для того, чтобы система работа корректно, вам необходимо установить расширение ZIP для PHP или же использовать версию PHP выше 5.3.'));
     } else {
         //            $this->object(new ZipArchive());
     }
 }
Пример #17
0
 /**
  * Init
  */
 public function init()
 {
     $this->regions = new Core_ArrayObject();
     hook('gear.request', array($this, 'handleGearRequest'));
     if ($favicon = config('theme.favicon')) {
         hook('theme.head.meta.after', array($this, 'renderFavicon'));
     }
     parent::init();
 }
Пример #18
0
 /**
  * Init
  *
  * With inheritance
  */
 public function init()
 {
     $parent = $this->reflection->getParentClass();
     if ($parent->name != 'Gear' && $parent->name != 'Theme') {
         $theme = new $parent->name();
         $theme->init();
     }
     parent::init();
 }
Пример #19
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     Template::bindGlobal('meta', $this->info);
     title(t(config('site.name', SITE_URL)));
     hook('head', array($this, 'head'), 0);
     hook('menu.setActive', array($this, 'menuTitleHook'));
     hook('Pages.showPage.before', array($this, 'showObjectTitle'));
     hook('admin.gear.request', array($this, 'showObjectTitle'));
 }
Пример #20
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if ($rules = $this->system_cache->read('access/rules', TRUE)) {
         $this->rules->adopt($rules);
     }
     if ($roles = $this->system_cache->read('access/roles', TRUE)) {
         $this->roles->adopt($roles);
     }
     $this->getRights();
     hook('exit', array($this, 'save'));
 }
Пример #21
0
 /**
  * Конструктор
  *
  * @param string $name
  */
 public function __construct($name)
 {
     $this->name = $name;
     event('template', $this);
     event('template.' . $name, $this);
     $path = Gear::preparePath($this->name);
     if (file_exists($path)) {
         $this->path = $path;
     } else {
         $message = t('Шаблон <b>%s</b> не найден по пути <u>%s</u>.', $name, $path);
         exit($message);
     }
 }
Пример #22
0
 /**
  * Preparation step before anything else.
  */
 public function __construct($errorReporting)
 {
     error_reporting($errorReporting);
     spl_autoload_register([$this, 'loader']);
     set_exception_handler('Resources\\RunException::main');
     set_error_handler('Resources\\RunException::errorHandlerCallback', error_reporting());
     $this->config['main'] = Resources\Config::main();
     $this->uriObj = new Resources\Uri();
     $this->uriObj->setDefaultController($this->config['main']['defaultController']);
     self::$uri = $this->uriObj;
     $this->firstUriPath = ucwords($this->uriObj->getClass());
     $this->controllerHandler();
 }
Пример #23
0
 /**
  * Constructor
  * 
  * @param string|array $options
  */
 public function __construct($options)
 {
     if (is_string($options)) {
         if (!($config = Config::read(Gear::preparePath($options, 'forms') . EXT))) {
             return error(t('Cannot read form config <b>%s</b>.', '', $options));
         } else {
             $options = $config;
         }
     } else {
         $options = Core_ArrayObject::transform($options);
     }
     parent::__construct($options, Options::SELF);
 }
Пример #24
0
 /**
  * Constructor
  * 
  * @param string $name
  */
 public function __construct($name)
 {
     parent::__construct($name);
     $path = Gear::preparePath($this->name, 'templates') . EXT;
     if (file_exists($path)) {
         $this->path = $path;
         //$this->code = file_get_contents($this->path);
         ini_get('short_open_tag') or $this->code = str_replace('<?=', '<?php echo', $this->code);
     } else {
         /**
          * There we have an option → render as normal error or with just simple exit.
          * If we try to render any Messages (success, notify or error template) we can be easliy catched by looping error throwing us into nowhere.
          * That's why we use such a hint there.
          */
         $message = t('Template <b>%s</b> is not found by path <u>%s</u>.', 'Errors', $this->name, $this->path);
         exit($message);
         //            strpos($this->name, 'Messages') !== FALSE ? exit($message) : error($message);
     }
 }
Пример #25
0
 /**
  * Конструктор
  *
  * @param string|array $options
  */
 public function __construct($options)
 {
     $this->elements = new Core_ArrayObject();
     if (is_string($options)) {
         $path = Gear::preparePath($options);
         if (!($config = Config::read($path))) {
             error(t('Не могу прочитать файл конфигурации формы по адресу <b>%s</b>.', $path));
             $options = $this->options;
         } else {
             $options = $config;
         }
     } else {
         $options = Core_ArrayObject::transform($options);
     }
     parent::__construct(Form::filterOptions($options));
     $this->defaults = new Config(cogear()->form->dir . DS . 'defaults' . EXT);
     $this->init();
     event('form.load', $this);
     event('form.load.' . $this->options->name, $this);
 }
Пример #26
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     $this->object(new User_Object());
     $this->object()->init();
 }
Пример #27
0
 /**
  * Constructor
  */
 public function __construct()
 {
     parent::__construct();
     $this->menu = new Core_ArrayObject();
 }
Пример #28
0
 /**
  * Конструктор
  */
 public function init()
 {
     parent::init();
     //        bind_route('user/([^/]+)/posts:maybe', array($this, 'list_action'), TRUE);
     //        bind_route('user/([^/]+)/drafts:maybe', array($this, 'drafts_action'), TRUE);
 }
Пример #29
0
 public static function getAvailableGearWithTypeAndExclusions($type, $co_id, $co_start, $co_end)
 {
     $results = self::getGearListWithType($type);
     if (is_null($co_id)) {
         //do not exclude any checkouts
         foreach ($results as $row) {
             //check if in stock for dates
             $gearObject = new Gear();
             $gearObject->fetch($row['gear_id']);
             if ($gearObject->availableQty($co_start, $co_end) > 0 && !$gearObject->isDisabled()) {
                 //add object to return array if in stock
                 $availableGear[] = $row;
             }
         }
     } else {
         //with exclusions
         foreach ($results as $row) {
             //check if in stock for dates
             $gearObject = new Gear();
             $gearObject->fetch($row['gear_id']);
             if ($gearObject->availableQtyExcludingCheckout($co_id, $co_start, $co_end) > 0 && !$gearObject->isDisabled()) {
                 //add object to return array if in stock
                 $availableGear[] = $row;
             }
         }
     }
     return $availableGear;
 }
Пример #30
0
<?php

// Sets the default timezone used by all date/time. Adjust to your location
date_default_timezone_set('Asia/Jakarta');
// You can adjust this following constants if necessary.
// The APP constant is where your application folder located.
define('APP', dirname(__FILE__) . '/../app/');
// The INDEX_FILE constant is this default file name.
define('INDEX_FILE', basename(__FILE__));
// And the GEAR constant is where panada folder located.
define('GEAR', dirname(__DIR__) . '/panada/');
require_once GEAR . 'Gear.php';
// To sets which PHP errors are reported just like documented in this page
// http://php.net/manual/en/function.error-reporting.php
// You can pass a parameter into the Gear class.
// Turn off all errors reporting - production use.
// Gear::send(0);
// By default all errors will displayed - development use.
Gear::send();