本文整理汇总了PHP中cogear函数的典型用法代码示例。如果您正苦于以下问题:PHP cogear函数的具体用法?PHP cogear怎么用?PHP cogear使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cogear函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: upload
/**
* Upload file
*
* @param string $name
* @param array $options
* @return string|boolean
*/
public function upload()
{
if ($files = cogear()->input->post[$this->name]) {
return $this->uploadOne($files);
}
return FALSE;
}
示例2: __construct
/**
* Constructor
*
* @param string $template
*/
public function __construct($name, $template = NULL, $base_uri = NULL)
{
parent::__construct($name);
cogear()->menu->register($name, $this);
$template && ($this->template = $template);
$this->base_uri = rtrim(parse_url($base_uri ? $base_uri : Url::link(), PHP_URL_PATH), '/') . '/';
}
示例3: load
/**
* Загрузка скриптов
*/
public function load()
{
$this->toolbar = Core_ArrayObject::transform($this->toolbar);
$folder = cogear()->redactor->folder . DS . 'redactor' . DS;
$options = new Core_ArrayObject();
event('redactor.options', $options);
$options->lang = config('i18n.lang', 'ru');
$options->shortcuts = TRUE;
$options->minHeight = 300;
$options->buttons = array('formatting', 'alignment', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'table', 'link', 'image', '|', 'fontcolor', 'backcolor', '|', 'horizontalrule', '|', 'html');
// $options->imageUpload = l('/redactor/upload/');
$options->fixed = TRUE;
$options->observeImages = TRUE;
$options->convertLinks = TRUE;
$options->cleanup = FALSE;
$options->focus = TRUE;
$options->convertDivs = FALSE;
role() == 1 && ($options->fixedTop = 40);
js($folder . $options->lang . '.js', 'after');
// $this->toolbar->markupSet->uasort('Core_ArrayObject::sortByOrder');
// $(document).ready(function(){
css($folder . 'redactor.css');
js($folder . 'redactor.min.js', 'after');
inline_js("\$('[name={$this->name}]').redactor(" . $options->toJSON() . ")", 'after');
}
示例4: init
/**
* 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'] = 'root';
}
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.');
}
}
示例5: init
/**
* Init
*/
public function init()
{
parent::init();
if (access('Dev.*') && cogear()->config->development) {
hook('done', array($this, 'finish'));
}
}
示例6: result
/**
* Process elements value from request
*
* @return
*/
public function result()
{
$method = $this->form->method;
$this->options->value = cogear()->input->{$method}($this->options->name) ? 1 : 0;
$this->is_fetched = TRUE;
return $this->validate() ? $this->options->value : FALSE;
}
示例7: render
/**
* Render list of users
*/
public function render()
{
$item = new $this->class();
$this->where && $this->db->where((array) $this->where);
$this->or_where && $this->db->or_where((array) $this->or_where);
$this->order && $this->db->order($this->order[0], $this->order[1]);
if ($this->where_in) {
foreach ($this->where_in->toArray() as $key => $value) {
$this->db->where_in($key, $value);
}
}
if ($this->in_set) {
foreach ($this->in_set as $key => $value) {
$this->db->in_set($key, $value);
}
}
if ($this->like) {
$i = 0;
foreach ($this->like as $like) {
$func = $i ? 'or_like' : 'like';
cogear()->db->{$func}($like[0], $like[1], isset($like[2]) ? $like[2] : 'after');
$i++;
}
}
$pager = new Pager(array('current' => $this->page ? $this->page : NULL, 'count' => $item->countAll(), 'per_page' => $this->per_page, 'base' => $this->base));
if ($items = $item->findAll()) {
return $this->process($items, $pager);
} else {
$this->options->showEmpty !== FALSE && event('empty');
return FALSE;
}
}
示例8: delete
/**
* Переопределение метода delete
*
* @return boolean
*/
public function delete()
{
if ($result = parent::delete($data)) {
cogear()->cache->remove('menu.' . $this->menu_id . '.items');
}
return $result;
}
示例9: index
/**
* Show pages
*
* @param string $type
*/
public function index($action = '', $subaction = NULL)
{
new Menu_Tabs('pages', Url::gear('pages'));
switch ($action) {
case 'create':
if (!page_access('pages create')) {
return;
}
$form = new Form('Pages.createdit');
if ($result = $form->result()) {
$page = new Pages_Object();
$page->object($result);
$page->aid = cogear()->user->id;
$page->created_date = time();
$page->last_update = time();
$page->save();
flash_success(t('New page has been successfully added!', 'Pages'));
redirect($page->getUrl());
}
append('content', $form->render());
break;
case 'show':
$this->showPage($subaction);
break;
case 'edit':
$page = new Pages_Object();
$page->where('id', intval($subaction));
if ($page->find()) {
if (access('pages edit_all') or $cogear->user->id == $page->aid) {
$form = new Form('Pages.createdit');
$form->init();
if (access('pages delete')) {
$form->addElement('delete', array('label' => t('Delete'), 'type' => 'submit'));
}
$form->setValues($page->object());
if ($result = $form->result()) {
if ($result->delete) {
$page->delete();
redirect(Url::gear('pages'));
}
$page->object()->mix($result);
$page->last_update = time();
$page->update();
$link = $page->getUrl();
success(t('Page has been update. You can visit it by link <a href="%s">%s</a>', 'Pages', $link, $link));
//redirect($page->getUrl());
}
$form->elements->submit->setValue(t('Update'));
append('content', $form->render());
} else {
return _403();
}
} else {
return _404();
}
break;
default:
$this->showPages($action);
}
}
示例10: decodeCallback
/**
* Раскодировка Callback
*
* @param type $callback
*/
public function decodeCallback($callback)
{
if ($data = explode(self::DELIM, $callback)) {
$class = array_shift($data);
$method = array_shift($data);
$args = $data;
$callback = array();
if (!class_exists($class)) {
return FALSE;
}
// Если это шестерёнка, то не надо её повторно создавать
if (strpos($class, Gears::GEAR)) {
$gear = substr($class, 0, strpos($class, '_' . Gears::GEAR));
if (cogear()->{$gear}) {
$callback[0] = cogear()->{$gear};
}
}
// Если массив всё ещё пустой
if (!$callback) {
$callback[0] = new $class();
}
// Если метод не существует — останавливаем
if (!method_exists($callback[0], $method)) {
return FALSE;
} else {
$callback[1] = $method;
}
return new Callback($callback, $args);
}
return FALSE;
}
示例11: result
/**
* Buttons data shouldn't be in result
*
* @return NULL
*/
public function result()
{
$method = strtolower($this->form->method);
$this->value = cogear()->input->{$method}($this->name);
$this->is_fetched = TRUE;
return $this->value ? TRUE : NULL;
}
示例12: __call
/**
* Magic __call method
*
* @param string $name
* @param array $array
*/
public function __call($name, $args)
{
$callback = new Callback(array(cogear(), $name));
if ($callback->check()) {
return $callback->run($args);
}
return NULL;
}
示例13: cache
/**
* Caching alias
*
* @param type $name
* @param type $value
* @param type $tags
* @param type $ttl
* @return type
*/
function cache($name, $value = NULL, $tags = array(), $ttl = 3600)
{
if ($value !== NULL) {
return cogear()->cache->write($name, $value, $tags, $ttl);
} else {
return cogear()->cache->read($name);
}
}
示例14: __construct
/**
* Constructor
*
* @param boolean $autoinit
*/
public function __construct($id = NULL)
{
parent::__construct('users');
if ($id) {
cogear()->db->where('id', $id);
$this->find();
}
}
示例15: session
/**
* Shortcut for session
*
* @param type $name
* @param type $value
*/
function session($name, $value = NULL)
{
if ($value !== NULL) {
cogear()->session->set($name, $value);
} else {
return cogear()->session->get($name);
}
}