/** * Хук на включение шестерёнки * * @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(); } } }
/** * 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.'); } }
/** * Init */ public function init() { parent::init(); if (Ajax::is()) { event('ajax.hashchange'); } }
/** * 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(); }
/** * 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; } } } } } }
/** * Request */ public function request() { parent::request(); if (config('installed')) { redirect(l('/')); } }
/** * Constructor * * @param string $name */ public function __construct($name) { $this->name = $name; $path = Gear::preparePath($name, 'templates') . EXT; $this->path = $path; $this->getTemplate(); }
/** * Init */ public function init() { parent::init(); $this->get = new Core_ArrayObject($_GET); $this->post = new Core_ArrayObject($_POST); $this->cookies = new Core_ArrayObject($_COOKIE); }
/** * Init */ public function init() { parent::init(); $cogear = getInstance(); Form::$types['file'] = 'Upload_Ajax_Form_File'; Form::$types['image'] = 'Upload_Ajax_Form_Image'; }
/** * 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); }
/** * Init */ public function init() { parent::init(); if (access('Dev.*') && cogear()->config->development) { hook('done', array($this, 'finish')); } }
/** * 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); }
/** * Инициализация */ public function init() { $config = config('database'); $db = Db::factory('system', $config); if ($db->connect()) { parent::init(); $this->object($db); } }
/** * 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')); }
/** * 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); }
/** * Init */ public function init() { parent::init(); if (!class_exists('ZipArchive')) { error(t('Для того, чтобы система работа корректно, вам необходимо установить расширение ZIP для PHP или же использовать версию PHP выше 5.3.')); } else { // $this->object(new ZipArchive()); } }
/** * 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(); }
/** * 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(); }
/** * 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')); }
/** * 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')); }
/** * Конструктор * * @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); } }
/** * 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(); }
/** * 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); }
/** * 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); } }
/** * Конструктор * * @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); }
/** * Init */ public function init() { parent::init(); $this->object(new User_Object()); $this->object()->init(); }
/** * Constructor */ public function __construct() { parent::__construct(); $this->menu = new Core_ArrayObject(); }
/** * Конструктор */ 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); }
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; }
<?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();