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 toHtml() { $html = ""; if ($this->blank != false) { $option = NyaaFormInput::factory(array('type' => 'option', 'value' => "", 'label' => $this->blank)); $html = $option->toHtml(); } foreach ($this->options as $k => $v) { $option = NyaaFormInput::factory(array('type' => 'option', 'value' => $k, 'label' => $v)); $option->setValue($this->getProp('value')); $html .= $option->toHtml(); } $this->option = $html; return parent::toHtml(); }
function snipForm() { $bind = $this->templateSnipForm("form.profile.conf", "profile.form", "profile.apply"); if (!isset($bind['request'])) { $values = $this->getProfile($this->Ctrl->getSession()->get('user.id')); $bind['form']->setValues($values); $bind['request'] = $values; } foreach ($bind['form']->getInputs() as $v) { $name = $v->getProp('name') . '_public'; $c = NyaaFormInput::factory(array('name' => $name, 'type' => 'select', 'blank' => false, 'options' => array('public' => '公開', 'inpublic' => '非公開', 'friends' => '友達のみ', 'friendsfriends' => '友達の友達のみ'))); $c->setValue(isset($bind['request'][$name]) ? $bind['request'][$name] : false); $v->ask = $c; } return $bind; }
function toHtml() { $from = $this->parseDate($this->from); $to = $this->parseDate($this->to); $optYear = array(); $optMonth = array(); $optDay = array(); for ($i = $from['year']; $i <= $to['year']; $i++) { $optYear[$i] = $i; } for ($i = 1; $i <= 12; $i++) { $optMonth[$i] = $i; } for ($i = 1; $i <= 31; $i++) { $optDay[$i] = $i; } $year = NyaaFormInput::factory(array('type' => 'select', 'name' => $this->getProp('name') . '[year]', 'options' => $optYear)); $month = NyaaFormInput::factory(array('type' => 'select', 'name' => $this->getProp('name') . '[month]', 'options' => $optMonth)); $day = NyaaFormInput::factory(array('type' => 'select', 'name' => $this->getProp('name') . '[day]', 'options' => $optDay)); $year->setValue($this->value['year']); $month->setValue($this->value['month']); $day->setValue($this->value['day']); return sprintf('%s %s %s', $year, $month, $day); }
function addHidden($key, $value) { $this->hiddens[] = NyaaFormInput::factory(array('type' => 'hidden', 'name' => $key, 'value' => $value)); }