示例#1
0
 function formFactory($conf, $key)
 {
     require_once 'form/form.class.php';
     $form = new NyaaForm();
     $form->loadFile($conf);
     $form->addHidden('__FORM_ID__', $key);
     return $form;
 }
示例#2
0
 function snipForm()
 {
     require_once 'form/form.class.php';
     $formFile = $this->Ctrl->getConf('root.dir') . '/conf/form.user.login.conf';
     $form = new NyaaForm();
     $form->loadFile($formFile);
     $form->addHidden('__FORM__', 'user.login.apply');
     $form->addHidden('__APPLY_FROM__', 'user.login.form');
     $bind = array('form' => $form, 'email' => $form->getInput('email'), 'password' => $form->getInput('password'), 'saveLogin' => $form->getInput('saveLogin'), 'toRegist' => $form->getInput('toRegist'), 'signin' => $form->getInput('signin'));
     $result = $this->Ctrl->getResult('user.login.form');
     if (!empty($result)) {
         $bind['errors'] = $result->getOr('errors', array());
         $form->setValues($result->getOr('request', array()));
     }
     return $bind;
 }
示例#3
0
 function run()
 {
     $Tpl = $this->getTemplater();
     require_once 'form/form.class.php';
     $form = new NyaaForm();
     $form->addHidden('__APPLY_FROM__', 'home');
     $form->addHidden('__FORM__', 'home.tweet');
     $form->addInput(NyaaFormInput::factory(array('type' => 'textarea', 'name' => 'tweet')));
     $form->addInput(NyaaFormInput::factory(array('type' => 'submit', 'label' => 'Tweet', 'name' => 'submit')));
     $Tpl->set('tweetForm', $form);
     $Tpl->set('id', $this->Ctrl->getSession()->get('user.id'));
     $url = "http://api.twitter.com/1/statuses/home_timeline.xml";
     $xml = simplexml_load_string($this->twitter->twitterApi($this->uid, $url, 'GET', array('count' => 10)));
     $ret = array();
     $ret["twieet"] = array();
     foreach ($xml->status as $status) {
         $arr = array();
         $arr['text'] = preg_replace('#@([a-zA-Z0-9_]+)#', '<a href="http://twitter.com/\\1" target="_blank">@\\1</a>', $status->text);
         $arr['name'] = $status->user->name;
         $arr['screen_name'] = $status->user->screen_name;
         $arr['created_at'] = $status->user->created_at;
         $arr['img'] = $status->user->profile_image_url;
         $arr['source'] = $status->source;
         $ret['twieet'][] = $arr;
     }
     $Tpl->set('twieet', $ret['twieet']);
     return $Tpl->fetch('home.html');
 }
 function snipForm()
 {
     $conf = 'form.user.register.conf';
     $formName = 'user.register.form';
     $applyName = 'user.register.apply';
     require_once 'form/form.class.php';
     $formFile = $this->Ctrl->getConf('root.dir') . '/conf/' . $conf;
     $form = new NyaaForm();
     $form->setEnctype('multipart/form-data');
     $form->loadFile($formFile);
     $form->addHidden('__FORM__', $applyName);
     $form->addHidden('__APPLY_FROM__', $formName);
     $bind = array('form' => $form);
     $email = $this->Request->isEmpty('email') ? '' : $this->Request->get('email');
     $result = $this->Ctrl->getResult($formName);
     if (!empty($email)) {
         $form->getInput('email')->setValue($email);
     }
     if (!empty($result)) {
         $bind['errors'] = $result->getOr('errors', array());
         $form->setValues($result->getOr('request', array()));
     }
     return $bind;
 }