当前位置: 首页>>代码示例>>PHP>>正文


PHP XoopsFormElementTray::__construct方法代码示例

本文整理汇总了PHP中XoopsFormElementTray::__construct方法的典型用法代码示例。如果您正苦于以下问题:PHP XoopsFormElementTray::__construct方法的具体用法?PHP XoopsFormElementTray::__construct怎么用?PHP XoopsFormElementTray::__construct使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XoopsFormElementTray的用法示例。


在下文中一共展示了XoopsFormElementTray::__construct方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: __construct

 /**
  * Constructor
  *
  * @param string    $form  the form calling the editor selection
  * @param string    $name  editor name
  * @param string    $value Pre-selected text value
  * @param bool      $nohtml
  * @param array     $allowed_editors
  *
  */
 public function __construct($form, $name = 'editor', $value = null, $nohtml = false, $allowed_editors = array())
 {
     parent::__construct(_SELECT);
     $this->allowed_editors = $allowed_editors;
     $this->form = $form;
     $this->name = $name;
     $this->value = $value;
     $this->nohtml = $nohtml;
 }
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:19,代码来源:formselecteditor.php

示例2: __construct

 /**
  * XoopsFormDateTime::XoopsFormDateTime()
  *
  * @param mixed   $caption  form field caption
  * @param mixed   $name     form variable name
  * @param integer $size     size of date select
  * @param integer $value    unix timestamp, defaults to now
  * @param mixed   $showtime control display of date and time elements
  *                           SHOW_BOTH, true  - show both date and time selectors
  *                           SHOW_DATE, false - only show date selector
  *                           SHOW_TIME        - only show time selector
  */
 public function __construct($caption, $name, $size = 15, $value = 0, $showtime = true)
 {
     parent::__construct($caption, ' ');
     switch ((int) $showtime) {
         case static::SHOW_DATE:
             $displayDate = true;
             $displayTime = false;
             break;
         case static::SHOW_TIME:
             $displayDate = false;
             $displayTime = true;
             break;
         default:
             $displayDate = true;
             $displayTime = true;
             break;
     }
     $value = (int) $value;
     $value = $value > 0 ? $value : time();
     $datetime = getdate($value);
     if ($displayDate) {
         $this->addElement(new XoopsFormTextDateSelect('', $name . '[date]', $size, $value));
     } else {
         $value = !is_numeric($value) ? time() : (int) $value;
         $value = $value == 0 ? time() : $value;
         $displayValue = date(_SHORTDATESTRING, $value);
         $this->addElement(new XoopsFormHidden($name . '[date]', $displayValue));
     }
     if ($displayTime) {
         $timearray = array();
         for ($i = 0; $i < 24; ++$i) {
             for ($j = 0; $j < 60; $j += 10) {
                 $key = $i * 3600 + $j * 60;
                 $timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
             }
         }
         ksort($timearray);
         $timeselect = new XoopsFormSelect('', $name . '[time]', $datetime['hours'] * 3600 + 600 * ceil($datetime['minutes'] / 10));
         $timeselect->addOptionArray($timearray);
         $this->addElement($timeselect);
     } else {
         $this->addElement(new XoopsFormHidden($name . '[time]', 0));
     }
 }
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:56,代码来源:formdatetime.php

示例3: __construct

 public function __construct($caption, $name, $size = 15, $value = 0)
 {
     parent::__construct($caption, '&nbsp;');
     $value = intval($value);
     $value = $value > 0 ? $value : time();
     $datetime = getDate($value);
     $this->addElement(new XoopsFormTextDateSelect('', $name . '[date]', $size, $value));
     $timearray = array();
     for ($i = 0; $i < 24; $i++) {
         for ($j = 0; $j < 60; $j = $j + 10) {
             $key = $i * 3600 + $j * 60;
             $timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
         }
     }
     ksort($timearray);
     $timeselect = new XoopsFormSelect('', $name . '[time]', $datetime['hours'] * 3600 + 600 * floor($datetime['minutes'] / 10));
     $timeselect->addOptionArray($timearray);
     $this->addElement($timeselect);
 }
开发者ID:trabisdementia,项目名称:xuups,代码行数:19,代码来源:formdatetime.php

示例4: __construct

 /**
  * @param      $caption
  * @param      $name
  * @param int  $size
  * @param int  $value
  * @param bool $showtime
  * @param bool $formatTimestamp
  */
 public function __construct($caption, $name, $size = 15, $value = 0, $showtime = true, $formatTimestamp = true)
 {
     parent::__construct($caption, '&nbsp;');
     $value = (int) $value;
     $value = $value > 0 ? $value : time();
     if ($formatTimestamp) {
         $value = strtotime(formatTimestamp($value));
     }
     $datetime = getdate($value);
     $this->addElement(new XoopsFormTextDateSelect('', $name . '[date]', $size, $value, $showtime));
     $timearray = array();
     for ($i = 0; $i < 24; ++$i) {
         for ($j = 0; $j < 60; $j += 10) {
             $key = $i * 3600 + $j * 60;
             $timearray[$key] = $j != 0 ? $i . ':' . $j : $i . ':0' . $j;
         }
     }
     ksort($timearray);
     $timeselect = new XoopsFormSelect('', $name . '[time]', $datetime['hours'] * 3600 + 600 * floor($datetime['minutes'] / 10));
     $timeselect->addOptionArray($timearray);
     $this->addElement($timeselect);
 }
开发者ID:trabisdementia,项目名称:publisher,代码行数:30,代码来源:formdatetime.php

示例5: __construct

 /**
  * Constructor
  *
  * @param string $caption          form element caption
  * @param string $name             form element name
  * @param bool   $includeAnonymous Include user "anonymous"?
  * @param mixed  $value            Pre-selected value (or array of them).
  *                                 For an item with massive members, such as "Registered Users", "$value"
  *                                 should be used to store selected temporary users only instead of all
  *                                 members of that item
  * @param int    $size             Number or rows. "1" makes a drop-down-list.
  * @param bool   $multiple         Allow multiple selections?
  */
 public function __construct($caption, $name, $includeAnonymous = false, $value = null, $size = 1, $multiple = false)
 {
     /**
      * @var mixed array|false - cache any result for this session.
      *            Some modules use multiple copies of this element on a single page, so this call will
      *            be made multiple times. This is only used when $value is null.
      * @todo this should be replaced with better interface, with autocomplete style search
      * and user specific MRU cache
      */
     static $queryCache = false;
     /**
      * @var int - limit to this many rows
      */
     $limit = 200;
     /**
      * @var string - cache time to live - will be interpreted by strtotime()
      */
     $cachettl = '+5 minutes';
     /**
      * @var string - cache key
      */
     $cachekey = 'formselectuser';
     $select_element = new XoopsFormSelect('', $name, $value, $size, $multiple);
     if ($includeAnonymous) {
         $select_element->addOption(0, $GLOBALS['xoopsConfig']['anonymous']);
     }
     $member_handler = xoops_getHandler('member');
     $value = is_array($value) ? $value : (empty($value) ? array() : array($value));
     $selectedUsers = array();
     if (count($value) > 0) {
         // fetch the set of uids in $value
         $criteria = new Criteria('uid', '(' . implode(',', $value) . ')', 'IN');
         $criteria->setSort('uname');
         $criteria->setOrder('ASC');
         $selectedUsers = $member_handler->getUserList($criteria);
     }
     // get the full selection list
     // we will always cache this version to reduce expense
     if (empty($queryCache)) {
         XoopsLoad::load('XoopsCache');
         $queryCache = XoopsCache::read($cachekey);
         if ($queryCache === false) {
             $criteria = new CriteriaCompo();
             if ($limit <= $member_handler->getUserCount()) {
                 // if we have more than $limit users, we will select who to show based on last_login
                 $criteria->setLimit($limit);
                 $criteria->setSort('last_login');
                 $criteria->setOrder('DESC');
             } else {
                 $criteria->setSort('uname');
                 $criteria->setOrder('ASC');
             }
             $queryCache = $member_handler->getUserList($criteria);
             asort($queryCache);
             XoopsCache::write($cachekey, $queryCache, $cachettl);
             // won't do anything different if write fails
         }
     }
     // merge with selected
     $users = $selectedUsers + $queryCache;
     $select_element->addOptionArray($users);
     if ($limit > count($users)) {
         parent::__construct($caption, '', $name);
         $this->addElement($select_element);
         return null;
     }
     xoops_loadLanguage('findusers');
     $js_addusers = "<script type='text/javascript'>\n            function addusers(opts)\n            {\n                var num = opts.substring(0, opts.indexOf(':'));\n                opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                var sel = xoopsGetElementById('" . $name . "');\n                var arr = new Array(num);\n                for (var n=0; n < num; n++) {\n                    var nm = opts.substring(0, opts.indexOf(':'));\n                    opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                    var val = opts.substring(0, opts.indexOf(':'));\n                    opts = opts.substring(opts.indexOf(':')+1, opts.length);\n                    var txt = opts.substring(0, nm - val.length);\n                    opts = opts.substring(nm - val.length, opts.length);\n                    var added = false;\n                    for (var k = 0; k < sel.options.length; k++) {\n                        if (sel.options[k].value == val) {\n                            added = true;\n                            break;\n                        }\n                    }\n                    if (added == false) {\n                        sel.options[k] = new Option(txt, val);\n                        sel.options[k].selected = true;\n                    }\n                }\n\n                return true;\n            }\n            </script>";
     $token = $GLOBALS['xoopsSecurity']->createToken();
     $action_tray = new XoopsFormElementTray('', ' | ');
     $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="var sel = xoopsGetElementById(\'' . $name . '\');for (var i = sel.options.length-1; i >= 0; i--) {if (!sel.options[i].selected) {sel.options[i] = null;}}; return false;">' . _MA_USER_REMOVE . '</a>'));
     $action_tray->addElement(new XoopsFormLabel('', '<a href="#" onclick="openWithSelfMain(\'' . XOOPS_URL . '/include/findusers.php?target=' . $name . '&amp;multiple=' . $multiple . '&amp;token=' . $token . '\', \'userselect\', 800, 600, null); return false;" >' . _MA_USER_MORE . '</a>' . $js_addusers));
     parent::__construct($caption, '<br><br>', $name);
     $this->addElement($select_element);
     $this->addElement($action_tray);
 }
开发者ID:geekwright,项目名称:XoopsCore25,代码行数:89,代码来源:formselectuser.php


注:本文中的XoopsFormElementTray::__construct方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。