Exemplo n.º 1
0
 /**
  * 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;
 }
Exemplo n.º 2
0
 /**
  * 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), '/') . '/';
 }
Exemplo n.º 3
0
 /**
  *  Загрузка скриптов
  */
 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');
 }
Exemplo n.º 4
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.');
     }
 }
Exemplo n.º 5
0
 /**
  * Init
  */
 public function init()
 {
     parent::init();
     if (access('Dev.*') && cogear()->config->development) {
         hook('done', array($this, 'finish'));
     }
 }
Exemplo n.º 6
0
 /**
  * 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;
 }
Exemplo n.º 7
0
 /**
  * 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;
     }
 }
Exemplo n.º 8
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;
                     }
                 }
             }
         }
     }
 }
Exemplo n.º 9
0
 /**
  * Переопределение метода delete
  *
  * @return boolean
  */
 public function delete()
 {
     if ($result = parent::delete($data)) {
         cogear()->cache->remove('menu.' . $this->menu_id . '.items');
     }
     return $result;
 }
Exemplo n.º 10
0
 /**
  * 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);
     }
 }
Exemplo n.º 11
0
 /**
  * Раскодировка 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;
 }
Exemplo n.º 12
0
 /**
  * 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;
 }
Exemplo n.º 13
0
 /**
  * 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;
 }
Exemplo n.º 14
0
/**
 * 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);
    }
}
Exemplo n.º 15
0
 /**
  * Constructor
  * 
  * @param   boolean $autoinit
  */
 public function __construct($id = NULL)
 {
     parent::__construct('users');
     if ($id) {
         cogear()->db->where('id', $id);
         $this->find();
     }
 }
Exemplo n.º 16
0
/**
 * 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);
    }
}
Exemplo n.º 17
0
 /**
  * Init pager
  */
 protected function init()
 {
     // Auto parse page from uri
     if ($this->current == 0) {
         switch ($this->method) {
             case self::PATH:
                 if ($uri = cogear()->router->getUri()) {
                     if (preg_match('#' . preg_quote($this->prefix) . '([\\d+])/?$#', $uri, $matches)) {
                         $this->options->current = $matches[1];
                     }
                 }
                 break;
             case self::GET:
                 $this->options->current = cogear()->input->get($this->prefix);
                 break;
         }
     }
     if ($this->options->per_page == 0) {
         $this->options->per_page = config('per_page', 5);
     }
     $this->pages_num = ceil($this->count / $this->per_page);
     if ($this->order == self::FORWARD) {
         $this->first = 1;
         $this->last = $this->pages_num;
     } else {
         $this->first = $this->pages_num;
         $this->last = 1;
     }
     if (!$this->current) {
         $this->options->current = $this->first;
     }
     if ($this->order == self::FORWARD) {
         $this->start = $this->per_page * ($this->current - 1);
         $this->prev = $this->current - 1;
         $this->next = $this->current + 1;
     } else {
         $this->start = ($this->first - $this->current) * $this->per_page;
         $this->prev = $this->current + 1;
         $this->next = $this->current - 1;
     }
     $this->options->autolimit && cogear()->db->limit($this->per_page, $this->start);
     if ($this->first == $this->current) {
         $this->first = NULL;
         $this->prev = NULL;
     }
     if ($this->first == $this->prev) {
         $this->first = NULL;
     }
     if ($this->last == $this->current) {
         $this->next = NULL;
         $this->last = NULL;
     }
     if ($this->last == $this->next) {
         $this->last = NULL;
     }
     $this->is_init = TRUE;
 }
Exemplo n.º 18
0
 /**
  * Render
  * 
  * @return string
  */
 public function render()
 {
     $this->options['lang'] = config('site.locale', 'en');
     extract((array) $this->options);
     cogear()->elfinder->load();
     inline_js("\$(document).ready(\r\n\t\tfunction()\r\n\t\t{\r\n                  var opts = {\r\n                    lang: '{$lang}',\r\n                    styleWithCSS: " . ($styleWithCSS ? 'true' : 'false') . ",\r\n                    width: '{$width}',\r\n                    height: {$height},\r\n                    toolbar: '{$toolbar}',\r\n                    cssfiles : ['" . Url::gear('elrte') . "/css/elrte-inner.css'],\r\n                    fmAllow: true,\r\n                    fmOpen: function(callback){\r\n                        \$(\"<div id='{$this->getId()}-elfinder'>\").elfinder({\r\n                            url: '" . Url::gear('elfinder') . "connector/',\r\n                            lang: '{$lang}',\r\n                            dialog : { width : 900, modal : true, title : '" . t('Files') . "' }, // открываем в диалоговом окне\r\n                            closeOnEditorCallback : true, // закрываем после выбора файла\r\n                            editorCallback : callback\r\n                        })\r\n                    }\r\n                };\r\n         \$('#{$this->getId()} textarea').elrte(opts);\r\n\t\t}\r\n\t);");
     event('elRTE.load', $this);
     return parent::render();
 }
Exemplo n.º 19
0
 /**
  * Хук парсера
  *
  * @param object $item
  */
 public function hookParse($item)
 {
     if ($item->body && strpos($item->body, '[pagelist')) {
         preg_match_all('#\\[pagelist(?:\\s+root=(\\d+)?)?\\]#i', $item->body, $matches);
         for ($i = 0; $i < sizeof($matches[0]); $i++) {
             $root = empty($matches[1][$i]) ? 1 : $matches[1][$i];
             $item->body = str_replace($matches[0][$i], cogear()->pages->getList($root), $item->body);
         }
     }
 }
Exemplo n.º 20
0
 /**
  * Удаляем сразу вместе со всеми элементами
  *
  * @return boolean
  */
 public function delete()
 {
     if ($result = parent::delete()) {
         cogear()->cache->remove('menu.' . $this->id . '.items');
         $item = new Menu_Db_Item();
         $item->menu_id = $this->id;
         $item->delete();
     }
     return $result;
 }
Exemplo n.º 21
0
 /**
  * Load scripts
  */
 public function load()
 {
     $folder = cogear()->markitup->folder . '/';
     css($folder . 'skins/simple/style.css');
     css($folder . 'sets/default/style.css');
     js($folder . 'js/jquery.markitup.js', 'after');
     $toolbar = Core_ArrayObject::transform($toolbar = array('nameSpace' => 'html', 'onCtrlEnter' => array('keepDefault' => FALSE, 'openWith' => "\n<p>", 'closeWith' => "</p>\n"), 'onTab' => array('keepDefault' => false, 'openWith' => '  '), 'markupSet' => array(array('name' => t('Bold'), 'key' => 'B', 'openWith' => '<b>', 'closeWith' => '</b>', 'className' => 'markItUpBold'), array('name' => t('Italic'), 'key' => 'I', 'openWith' => '<i>', 'closeWith' => '</i>', 'className' => 'markItUpItalic'), array('name' => t('Underlined'), 'key' => 'U', 'openWith' => '<u>', 'closeWith' => '</u>', 'className' => 'markItUpUndeline'), array('name' => t('Strike through'), 'key' => 'S', 'openWith' => '<s>', 'closeWith' => '</s>', 'className' => 'markItUpStrike'), array('name' => t('Heading 1'), 'key' => '1', 'openWith' => '<h1>', 'closeWith' => '</h1>', 'className' => 'markItUpH1'), array('name' => t('Heading 2'), 'key' => '2', 'openWith' => '<h2>', 'closeWith' => '</h2>', 'className' => 'markItUpH2'), array('name' => t('Heading 3'), 'key' => '3', 'openWith' => '<h3>', 'closeWith' => '</h3>', 'className' => 'markItUpH3'), array('name' => t('UL'), 'multiline' => true, 'openBlockWith' => "<ul>\n", 'closeBlockWith' => "\n</ul>\n", 'openWith' => " <li>", 'closeWith' => "</li>", 'className' => 'markItUpUl'), array('name' => t('OL'), 'multiline' => true, 'openBlockWith' => "<ol>\n", 'closeBlockWith' => "\n</ol>\n", 'openWith' => " <li>", 'closeWith' => "</li>", 'className' => 'markItUpOl'), array('name' => t('Picture'), 'key' => 'P', 'replaceWith' => '<img src="[![Source:!:http://]!]" alt="" />', 'className' => 'markItUpPicture'), array('name' => t('Link'), 'key' => 'L', 'openWith' => '<a href="[![Link:!:http://]!]">', 'closeWith' => '</a>', 'className' => 'markItUpLink'), array('name' => t('User'), 'key' => 'U', 'openWith' => '[user=[![User]!]]', 'className' => 'markItUpUser'), array('name' => t('Code'), 'key' => 'O', 'openWith' => '<pre class="prettyprint linenums"><code>', 'closeWith' => '</code></pre>', 'className' => 'markItUpCode'))));
     event('markitup.toolbar', $toolbar);
     inline_js("\$('[name={$this->name}]').markItUp(" . $toolbar->toJSON() . ")", 'after');
 }
Exemplo n.º 22
0
 /**
  * Filter
  *
  * @value
  */
 public function filter($value)
 {
     if (access('Parser.off') && cogear()->input->post('parser_off')) {
         return $value;
     }
     $jevix = new Parser_Jevix();
     //Конфигурация
     $allowed_tags = array('a', 'img', 'i', 'b', 'u', 'em', 'strong', 'nobr', 'li', 'ol', 'ul', 'sup', 'abbr', 'pre', 'acronym', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'cut', 'user', 'br', 'code', 'p', 'video');
     // 1. Устанавливаем разрешённые теги. (Все не разрешенные теги считаются запрещенными.)
     $jevix->cfgAllowTags($allowed_tags);
     // 2. Устанавливаем коротие теги. (не имеющие закрывающего тега)
     $jevix->cfgSetTagShort(array('br', 'img'));
     // 3. Устанавливаем преформатированные теги. (в них все будет заменятся на HTML сущности)
     $jevix->cfgSetTagPreformatted(array('code'));
     // 4. Устанавливаем теги, которые необходимо вырезать из текста вместе с контентом.
     $jevix->cfgSetTagCutWithContent(array('script', 'object', 'iframe', 'style'));
     // 5. Устанавливаем разрешённые параметры тегов. Также можно устанавливать допустимые значения этих параметров.
     $jevix->cfgAllowTagParams('a', array('title', 'href', 'class'));
     $jevix->cfgAllowTagParams('img', array('src', 'alt' => '#text', 'title', 'align' => array('right', 'left', 'center'), 'width' => '#int', 'height' => '#int', 'hspace' => '#int', 'vspace' => '#int', 'class'));
     $jevix->cfgAllowTagParams('code', array('class'));
     $jevix->cfgAllowTagParams('p', array('align' => array('left', 'right', 'center')));
     $jevix->cfgAllowTagParams('pre', array('class'));
     // 6. Устанавливаем параметры тегов являющиеся обязяательными. Без них вырезает тег оставляя содержимое.
     $jevix->cfgSetTagParamsRequired('img', 'src');
     $jevix->cfgSetTagParamsRequired('a', 'href');
     // 7. Устанавливаем теги которые может содержать тег контейнер
     //    cfgSetTagChilds($tag, $childs, $isContainerOnly, $isChildOnly)
     //       $isContainerOnly : тег является только контейнером для других тегов и не может содержать текст (по умолчанию false)
     //       $isChildOnly : вложенные теги не могут присутствовать нигде кроме указанного тега (по умолчанию false)
     //$jevix->cfgSetTagChilds('ul', 'li', true, false);
     // 8. Устанавливаем атрибуты тегов, которые будут добавлятся автоматически
     $jevix->cfgSetTagParamDefault('a', 'rel', null, true);
     //$jevix->cfgSetTagParamsAutoAdd('a', array('rel' => 'nofollow'));
     //$jevix->cfgSetTagParamsAutoAdd('a', array('name'=>'rel', 'value' => 'nofollow', 'rewrite' => true));
     //        $jevix->cfgSetTagParamDefault('img', 'width', '300px');
     //        $jevix->cfgSetTagParamDefault('img', 'height', '300px');
     //$jevix->cfgSetTagParamsAutoAdd('img', array('width' => '300', 'height' => '300'));
     //$jevix->cfgSetTagParamsAutoAdd('img', array(array('name'=>'width', 'value' => '300'), array('name'=>'height', 'value' => '300') ));
     // 9. Устанавливаем автозамену
     $jevix->cfgSetAutoReplace(array(' -- ', '+/-', '(c)', '(r)'), array(' &mdash; ', '±', '©', '®'));
     // 10. Включаем или выключаем режим XHTML. (по умолчанию включен)
     $jevix->cfgSetXHTMLMode(TRUE);
     // 11. Включаем или выключаем режим замены переноса строк на тег <br/>. (по умолчанию включен)
     $jevix->cfgSetAutoBrMode(TRUE);
     // 12. Включаем или выключаем режим автоматического определения ссылок. (по умолчанию включен)
     $jevix->cfgSetAutoLinkMode(FALSE);
     // 13. Отключаем типографирование в определенном теге
     $jevix->cfgSetTagNoTypography(array('code', 'pre'));
     //        $jevix->cfgSetTagNoTypography('pre');
     event('jevix', $jevix);
     $errors = array();
     $result = $jevix->parse($value, $errors);
     return $result;
 }
Exemplo n.º 23
0
 /**
  * Constructir
  *
  * @param string $table
  * @param string $primary
  */
 public function __construct($table = NULL, $primary = NULL)
 {
     parent::__construct();
     $this->clear();
     $table && ($this->table = $table);
     $this->fields = cogear()->db->getFields($this->table);
     $this->reflection = new ReflectionClass($this);
     $fields = array_keys((array) $this->fields);
     $first = reset($fields);
     $this->primary = $primary ? $primary : $first;
 }
Exemplo n.º 24
0
 /**
  * Process elements value from request
  *
  * @return
  */
 public function result()
 {
     if ($this->options->disabled) {
         return NULL;
     }
     $method = strtolower($this->form->method);
     $name = str_replace('[]', '', $this->name);
     $this->value = cogear()->input->{$method}($name);
     $this->filtrate();
     $result = $this->validate() ? $this->value : FALSE;
     return $result;
 }
Exemplo n.º 25
0
 /**
  * Process elements value from request
  *
  * @return
  */
 public function result()
 {
     $cogear = cogear();
     $file = new File_Url_Upload($this->prepareOptions());
     if ($value = $file->upload()) {
         $this->is_fetched = TRUE;
         $this->value = $value;
     } else {
         $this->errors = $file->errors;
         $this->value = $this->options->value;
     }
     return $this->value;
 }
Exemplo n.º 26
0
 /**
  * Create new post
  *
  * @param type $data
  */
 public function insert($data = NULL)
 {
     $data or $data = $this->object()->toArray();
     if (NULL === session('converter.adapter')) {
         $data['created_date'] = time();
         $data['ip'] = cogear()->session->get('ip');
         $data['last_update'] = time();
         $data['aid'] = cogear()->user->id;
     }
     if ($result = parent::insert($data)) {
         event('post.insert', $this, $data, $result);
     }
     return $result;
 }
Exemplo n.º 27
0
 /**
  * Привод строки к виду url
  *
  * Transform text to url-compatible snippet
  *
  * @param   string  $text
  * @param   string  $separator
  * @param   int     $limit
  * @return  string
  */
 public static function name($text, $separator = '-', $limit = 40)
 {
     $text = cogear()->lang->transliterate($text);
     $text = preg_replace("/[^a-z0-9\\_\\-.]+/mi", "", $text);
     $text = preg_replace('#[\\-]+#i', $separator, $text);
     $text = strtolower($text);
     if (strlen($text) > $limit) {
         $text = substr($text, 0, $limit);
         if ($temp_max = strrpos($text, '-')) {
             $text = substr($text, 0, $temp_max);
         }
     }
     return $text;
 }
Exemplo n.º 28
0
 /**
  * Панель управления
  */
 public function admin_action()
 {
     $form = new Form("Wysiwyg/forms/config");
     $options = new Core_ArrayObject();
     $options->type = config('wysiwyg.editor');
     $form->type->setValues(self::$editors);
     $form->object($options);
     if ($result = $form->result()) {
         if (isset(self::$editors[$result['type']])) {
             cogear()->set('wysiwyg.editor', $result['type']);
             success(t('Конфигурация успешно сохранена.'));
         }
     }
     append('content', $form->render());
 }
Exemplo n.º 29
0
 /**
  * Get fields
  *
  * @return  Core_ArrayObject
  */
 public function getFields()
 {
     if ($this->fields) {
         return $this->fields;
     } else {
         $fields = array('login' => array('label' => t('Имя пользователя'), 'callback' => new Callback(array($this, 'prepareFields'))));
         if (cogear()->gears->Post) {
             $fields += array('posts' => array('label' => t('Публикаций'), 'callback' => new Callback(array($this, 'prepareFields')), 'class' => 't_c w10'));
         }
         if (cogear()->Comments) {
             $fields += array('comments' => array('label' => t('Комментариев'), 'callback' => new Callback(array($this, 'prepareFields')), 'class' => 't_c w10'));
         }
         $fields += array('reg_date' => array('label' => t('Зарегистрирован'), 'callback' => new Callback(array($this, 'prepareFields'))));
         return $this->setFields($fields);
     }
 }
Exemplo n.º 30
0
 /**
  * Control Panel
  */
 public function admin()
 {
     $form = new Form("Wysiwyg.config");
     $options = new Core_ArrayObject();
     $options->editor = config('wysiwyg.editor');
     $form->init();
     $form->elements->type->setValues(self::$editors);
     $form->object($options);
     if ($result = $form->result()) {
         if (isset(self::$editors[$result['type']])) {
             cogear()->set('wysiwyg.editor', $result['type']);
             success('Configuration saved successfully.');
         }
     }
     append('content', $form->render());
 }