Пример #1
0
 public function index($file = 'TODO.md')
 {
     $todo = file_get_contents(ROW_PATH . '/' . $file);
     $todo = Output::markdown($todo);
     $this->tpl->display(false, array('content' => $todo));
     // Show no View, only Layout
 }
Пример #2
0
 public function renderElementWrapperWithTitle($input, $element)
 {
     if (!$this->options->table) {
         return parent::renderElementWrapperWithTitle($input, $element);
     }
     $name = $element['_name'];
     $description = empty($element['description']) ? '' : '<span class="icon help" title="' . Output::html($element['description']) . '">HELP</span>';
     $html = '<th class="' . $this->elementWrapperClasses($element) . '">' . $description . $element['title'] . '</th>';
     $html .= '<td class="input ' . $this->elementWrapperClasses($element) . '">' . $input . '</td>';
     return $this->renderElementWrapper($html, $element);
 }
Пример #3
0
 public function csv_archive($name = 'archive.csv')
 {
     $posts = models\Post::all('is_published = 1 order by post_id desc');
     if (!$posts) {
         Session::error('Archive empty =)');
         $this->_redirect('blog');
     }
     $this->_download($name, 'text/plain');
     echo \app\specs\Output::csv(array_keys((array) $posts[0]), false);
     foreach ($posts as $post) {
         echo \app\specs\Output::csv($post, false);
     }
     exit;
     // No parse time
 }
Пример #4
0
 public function code()
 {
     if (!isset($_POST['code'])) {
         $_POST['code'] = 'print_r($_GET);';
     }
     $code = $_POST['code'];
     $db = $GLOBALS['db'];
     echo '<pre>';
     try {
         eval($code);
     } catch (\Exception $ex) {
         echo "\n=================== exception ====================\n\n";
         print_r($ex);
     }
     echo '</pre><br><br><hr>';
     echo '<form method="post"><textarea rows=20 cols=120 name=code>' . Output::html($code) . '</textarea><br><input type=submit></form>';
 }
Пример #5
0
 public function code($password)
 {
     if (sha1(ROW_APP_SECRET . ':' . $password) != 'b9885c8c4972c625fbcad44adb954acc87e2771b') {
         return $this->dispatcher->throwNotFound();
     }
     if (!isset($_POST['code'])) {
         $_POST['code'] = 'print_r($_GET);';
     }
     $code = $_POST['code'];
     $db = $GLOBALS['db'];
     echo '<pre>';
     try {
         eval($code);
     } catch (\Exception $ex) {
         echo "\n=================== exception ====================\n\n";
         print_r($ex);
     }
     echo '</pre><br><br><hr>';
     echo '<form method="post" action><textarea rows=20 cols=120 name=code>' . Output::html($code) . '</textarea><br><input type=submit></form>';
 }
Пример #6
0
 protected function elements($defaults)
 {
     $this->options->oninput = 'this.op.value=this.username.value;';
     return array(array('type' => 'markup', 'inside' => function ($form) {
         return 'Username: <output name="op" xoninput="alert(this);this.value=this.form.username.value;">...</output>';
     }), 'username' => array('type' => 'text', 'required' => true, 'minlength' => 2, 'validation' => function ($form) {
         $db = $form->application->db;
         $usernameExists = models\User::count(array('username' => $form->input('username')));
         return $usernameExists ? 'This username is taken' : true;
     }, 'description' => Output::translate('Have you read our %1?', array(Output::ajaxLink(Output::translate('username guidelines', null, array('ucfirst' => false)), 'blog/page/username')))), 'password' => array('type' => 'password', 'required' => true, 'minlength' => 0), 'color' => array('title' => 'Favourite colour', 'type' => 'colour', 'required' => true, 'minlength' => 2, 'default' => 'white'), 'category' => array('title' => 'Favourite blog category', 'type' => 'options', 'options' => \app\models\Category::all('category_name <> ?', ''), 'dummy' => '-- I have not the favourite', 'validation' => function ($form, $name) {
         if ('' == $form->input($name, '')) {
             // Can be empty
             $form->output($name, null);
             return true;
         }
         return $form->validateOptions($form, $name);
     }), 'birthdate' => array('title' => 'When\'s your dob?', 'type' => 'date', 'required' => true, 'validation' => 'date', 'default' => 'YYYY-MM-DD'), 'bio' => array('type' => 'textarea', 'required' => true, 'minlength' => 0, 'rows' => 5, 'regex' => '.*\\w\\s\\w.*'), array('type' => 'markup', 'outside' => '<fieldset><legend>' . Output::translate('Options') . '</legend>'), 'stupid' => array('type' => 'checkbox', 'required' => true, 'name' => 'options[stupid]'), 'this' => array('type' => 'checkbox', 'name' => 'options[this]'), 'that' => array('type' => 'checkbox', 'name' => 'options[that]'), array('type' => 'markup', 'outside' => '</fieldset>'), 'email' => array('type' => 'email', 'required' => true, 'validation' => 'email', 'description' => Output::translate('Only used for account activation. <strong>We won\'t store this.</strong>')), 'gender' => array('type' => 'radio', 'required' => true, 'options' => array('m' => Output::translate('Male'), 'f' => Output::translate('Female'))), 'hobbies' => array('type' => 'checkboxes', 'options' => models\Category::all(), 'required' => true, 'minlength' => 2, 'name' => 'misc[hobbies][]'), array('type' => 'markup', 'outside' => '<fieldset><legend>Terms</legend>'), 'terms' => array('type' => 'checkbox', 'title' => Output::translate('I very much do agree on the terms yes yes'), 'description' => 'Do you really? Huh? <b>Well?? Do ya??</b>', 'required' => true), array('type' => 'markup', 'outside' => '</fieldset>'), array('validation' => function ($form) {
         return strlen($form->input('username')) <= strlen($form->input('password'));
     }, 'fields' => 'password', 'message' => 'Your password must be at least as long as your username'), array('require' => 'username', 'validation' => function ($form) {
         $usr = strtolower($form->input('username'));
         $clr = strtolower($form->input('color'));
         return !is_int(strpos($usr, $clr)) && !is_int(strpos($clr, $usr));
     }, 'fields' => array('username', 'color'), 'message' => 'Username cannot contain Colour and vice versa'));
 }
Пример #7
0
    {
        return static::_all('1 order by created_on desc limit ' . (int) $amount);
    }
    public static function _newestPublished($amount)
    {
        return static::_all('is_published = 1 order by created_on desc limit ' . (int) $amount);
    }
    public static function _query()
    {
        return array('tables' => array('posts', 'categories c'), 'fields' => array('c.*', 'posts.*'), 'conditions' => array('c.category_id = posts.category_id'));
    }
}
/**/
Post::event(array('_insert'), function ($self, $args, $chain) {
    if (isset($args->values['title']) && !isset($args->values['original_slug'])) {
        $slug = Output::slugify($args->values['title']);
        //var_dump($slug);
        $slugs = Post::all("original_slug LIKE ?", $slug . '%');
        if ($slugs) {
            $nums = array();
            $slugs = array_map(function ($post) use($slug, &$nums) {
                $nums[] = (int) substr($post->original_slug, strlen($slug) + 1);
                return $post->original_slug;
            }, $slugs);
            rsort($nums, SORT_NUMERIC);
            //print_r($slugs);
            //print_r($nums);
            $slug .= '-' . ($nums[0] + 1);
            //var_dump($slug);
        }
        //exit;
Пример #8
0
 protected function elements($defaults)
 {
     return array('password' => array('type' => 'password', 'description' => Output::translate('Admin password to prove you\'re one of the hims/hers.'), 'required' => true, 'minlength' => 4), 'prefs' => array('type' => 'grid', 'subtype' => 'checkbox', 'reverse' => true, 'title' => Output::translate('Choose categories'), 'horizontal' => array(Output::translate('Domain'), models\Domain::all('domain_id >= ?', $this->options->domain ? $this->options->domain->domain_id : 0)), 'vertical' => array(Output::translate('User'), models\User::all('user_id >= ?', $this->options->user ? $this->options->user->user_id : 0)), 'description' => Output::translate('One category per user / domain combination'), 'name' => 'options'), 'cat' => array('type' => 'options', 'options' => models\Category::all()));
 }
Пример #9
0
<?php

use app\specs\Output;
?>
<pre>errors:
<? print_r($validator->errors) ?></pre>

<pre>comment:
<? var_export($comment) ?></pre>

<form method=post action=<?php 
echo Output::url($app->uri);
?>
>
<fieldset>
	<legend><?if(!$comment):?>Add comment<?else:?>Edit comment # <?php 
echo $comment->comment_id;
?>
<?endif?></legend>

	<?if( !$comment && !$app->user->isLoggedIn() ):?>

		<p class="field <?php 
echo $validator->ifError('username');
?>
">Your username:<br><input name=username value="<?php 
echo $this::html($validator->valueFor('username'));
?>
"><br><span class="errmsg"><?php 
echo $validator->getError('username');
?>
Пример #10
0
use row\auth\Session;
class Output extends \row\Output
{
    public function display($tpl = true, $vars = null, $layout = true)
    {
        $this->assign('messages', Session::messages());
        return parent::display($tpl, $vars, $layout);
    }
    protected function _init()
    {
        parent::_init();
        $this->assign('Application', $this::$application);
        $this->assign('User', $this::$application->user);
    }
    public static function ajaxlink($text, $path, $options = array())
    {
        $options['onclick'] = 'return openInAjaxPopup(this.href);';
        return static::link($text, $path, $options);
    }
    public static function ajaxActionlink($text, $path, $options = array())
    {
        if (isset($options['action'])) {
            $options['onclick'] = 'return doAjaxAction(this, ' . $options['action'] . ');';
            unset($options['action']);
        }
        return static::link($text, $path, $options);
    }
}
Output::$class = 'app\\specs\\Output';
Пример #11
0
 protected function elements($defaults)
 {
     return array('username' => array('type' => 'text', 'required' => true, 'minlength' => 2, 'validation' => 'unique', 'unique' => array('model' => 'app\\models\\User', 'field' => 'username', 'conditions' => array('user_id <> ?', array($defaults->user_id))), 'description' => Output::translate('Have you read our %1?', array(Output::ajaxLink(Output::translate('username guidelines', null, array('ucfirst' => false)), 'blog/page/username')))), 'password' => array('type' => 'text', 'minlength' => 2, 'description' => Output::html(Output::translate('Current password: %1', array($defaults->password)))), 'full_name' => array('type' => 'text', 'required' => true, 'minlength' => 3), 'bio' => array('type' => 'textarea'), 'access' => array('type' => 'text', 'validation' => 'csv'), 'domains' => array('type' => 'text', 'validation' => 'csv', 'storage' => 'in_domains', 'description' => Output::translate('Comma (+ space) separated. Will be checked individually and created if no existo.')));
 }