Esempio n. 1
0
 /**
  * Adds additional fields of used by the BlogTNG plugin to the editor.
  */
 function handle_editform_output(&$event, $param)
 {
     global $ID;
     $pos = $event->data->findElementByAttribute('type', 'submit');
     if (!$pos) {
         return;
     }
     // no submit button found, source view
     $pos -= 1;
     $pid = md5($ID);
     $this->entryhelper->load_by_pid($pid);
     $blog = $this->tools->getParam('post/blog');
     if (!$blog) {
         $blog = $this->entryhelper->get_blog();
     }
     $blogs = $this->entryhelper->get_blogs();
     $event->data->insertElement($pos, form_openfieldset(array('_legend' => 'BlogTNG', 'class' => 'edit', 'id' => 'blogtng__edit')));
     $pos += 1;
     $event->data->insertElement($pos, form_makeMenuField('btng[post][blog]', $blogs, $blog, 'Blog', 'blogtng__blog', 'edit'));
     $pos += 1;
     $this->taghelper->load($pid);
     $allowed_tags = $this->_get_allowed_tags();
     $tags = $this->_get_post_tags();
     if (!$tags) {
         $tags = $this->taghelper->tags;
     }
     if (count($allowed_tags) > 0) {
         $event->data->insertElement($pos++, form_makeOpenTag('div'));
         foreach ($this->_get_allowed_tags() as $val) {
             $data = array('style' => 'margin-top: 0.3em;');
             if (in_array($val, $tags)) {
                 $data['checked'] = 'checked';
             }
             $event->data->insertElement($pos++, form_makeCheckboxField('btng[post][tags][]', $val, $val, '', '', $data));
         }
         $event->data->insertElement($pos++, form_makeCloseTag('div'));
     } else {
         $event->data->insertElement($pos, form_makeTextField('btng[post][tags]', join(', ', $tags), 'Tags', 'blogtng__tags', 'edit'));
         $pos += 1;
     }
     if ($this->getConf('editform_set_date')) {
         $postdate = $this->tools->getParam('post/date');
         if ($postdate) {
             $YY = $postdate['YY'];
             $MM = $postdate['MM'];
             $DD = $postdate['DD'];
             $hh = $postdate['hh'];
             $mm = $postdate['mm'];
         } else {
             $created = $this->entryhelper->entry['created'];
             if ($created) {
                 $YY = strftime('%Y', $created);
                 $MM = strftime('%m', $created);
                 $DD = strftime('%d', $created);
                 $hh = strftime('%H', $created);
                 $mm = strftime('%M', $created);
             } else {
                 $time = mktime();
                 $YY = strftime('%Y', $time);
                 $MM = strftime('%m', $time);
                 $DD = strftime('%d', $time);
                 $hh = strftime('%H', $time);
                 $mm = strftime('%M', $time);
             }
         }
         $event->data->insertElement($pos, form_makeTextField('btng[post][date][YY]', $YY, 'YYYY', 'blogtng__date_YY', 'edit', array('maxlength' => 4)));
         $pos += 1;
         $event->data->insertElement($pos, form_makeTextField('btng[post][date][MM]', $MM, 'MM', 'blogtng__date_MM', 'edit', array('maxlength' => 2)));
         $pos += 1;
         $event->data->insertElement($pos, form_makeTextField('btng[post][date][DD]', $DD, 'DD', 'blogtng__date_DD', 'edit', array('maxlength' => 2)));
         $pos += 1;
         $event->data->insertElement($pos, form_makeTextField('btng[post][date][hh]', $hh, 'hh', 'blogtng__date_hh', 'edit', array('maxlength' => 2)));
         $pos += 1;
         $event->data->insertElement($pos, form_makeTextField('btng[post][date][mm]', $mm, 'mm', 'blogtng__date_mm', 'edit', array('maxlength' => 2)));
         $pos += 1;
     }
     $event->data->insertElement($pos, form_makeMenuField('btng[post][commentstatus]', array('enabled', 'closed', 'disabled'), $this->entryhelper->entry['commentstatus'], $this->getLang('commentstatus'), 'blogtng__commentstatus', 'edit'));
     $pos += 1;
     $event->data->insertElement($pos, form_closefieldset());
 }
Esempio n. 2
0
 /**
  * Add the oAuth login links
  *
  * @param Doku_Event $event  event object by reference
  * @param mixed      $param  [the parameters passed as fifth argument to register_hook() when this
  *                           handler was registered]
  * @return void
  */
 public function handle_loginform(Doku_Event &$event, $param)
 {
     global $conf;
     /** @var helper_plugin_oauth $hlp */
     $hlp = plugin_load('helper', 'oauth');
     $singleService = $this->getConf('singleService');
     $enabledServices = $hlp->listServices();
     /** @var Doku_Form $form */
     $form =& $event->data;
     $html = '';
     if ($singleService == '') {
         foreach ($hlp->listServices() as $service) {
             $html .= $this->service_html($service);
         }
         if (!$html) {
             return;
         }
     } else {
         if (in_array($singleService, $enabledServices, true) === false) {
             msg($this->getLang('wrongConfig'), -1);
             return;
         }
         $form->_content = array();
         $html = $this->service_html($singleService);
     }
     $form->_content[] = form_openfieldset(array('_legend' => $this->getLang('loginwith'), 'class' => 'plugin_oauth'));
     $form->_content[] = $html;
     $form->_content[] = form_closefieldset();
 }