Exemplo n.º 1
0
 /**
  * @param        $name
  * @param        $parent
  * @param   array  $options
  * @param   array  $params
  * @param   null   $attribs
  * @param   string $key
  * @param   string $text
  * @param   array  $selected
  * @param   bool   $idtag
  * @param   bool   $translate
  *
  * @return string
  */
 public static function categorylist($name, $parent, $options = array(), $params = array(), $attribs = null, $key = 'value', $text = 'text', $selected = array(), $idtag = false, $translate = false)
 {
     $preselect = isset($params['preselect']) ? (bool) ($params['preselect'] && $params['preselect'] != 'false') : true;
     $unpublished = isset($params['unpublished']) ? (bool) $params['unpublished'] : 0;
     $sections = isset($params['sections']) ? (bool) $params['sections'] : 0;
     $ordering = isset($params['ordering']) ? (string) $params['ordering'] : 'ordering';
     $direction = isset($params['direction']) && $params['direction'] == 'desc' ? -1 : 1;
     $action = isset($params['action']) ? (string) $params['action'] : 'read';
     $levels = isset($params['levels']) ? (int) $params['levels'] : 10;
     $topleveltxt = isset($params['toplevel']) ? $params['toplevel'] : false;
     $catid = isset($params['catid']) ? (int) $params['catid'] : 0;
     $hide_lonely = isset($params['hide_lonely']) ? (bool) $params['hide_lonely'] : 0;
     $params = array();
     $params['ordering'] = $ordering;
     $params['direction'] = $direction;
     $params['unpublished'] = $unpublished;
     $params['action'] = $action;
     $params['selected'] = $catid;
     if ($catid) {
         $category = KunenaForumCategoryHelper::get($catid);
         if (!$category->getParent()->authorise($action) && !KunenaUserHelper::getMyself()->isAdmin()) {
             $categories = KunenaForumCategoryHelper::getParents($catid, $levels, $params);
         }
     }
     $channels = array();
     if (!isset($categories)) {
         $category = KunenaForumCategoryHelper::get($parent);
         $children = KunenaForumCategoryHelper::getChildren($parent, $levels, $params);
         if ($params['action'] == 'topic.create') {
             $channels = $category->getChannels();
             if (empty($children) && !isset($channels[$category->id])) {
                 $category = KunenaForumCategoryHelper::get();
             }
             foreach ($channels as $id => $channel) {
                 if (!$id || $category->id == $id || isset($children[$id]) || !$channel->authorise($action)) {
                     unset($channels[$id]);
                 }
             }
         }
         $categories = $category->id > 0 ? array($category->id => $category) + $children : $children;
         if ($hide_lonely && count($categories) + count($channels) <= 1) {
             return;
         }
     }
     if (!is_array($options)) {
         $options = array();
     }
     if ($selected === false || $selected === null) {
         $selected = array();
     } elseif (!is_array($selected)) {
         $selected = array((string) $selected);
     }
     if ($topleveltxt) {
         $me = KunenaUserHelper::getMyself();
         $disabled = $action == 'admin' && !$me->isAdmin();
         $options[] = JHtml::_('select.option', '0', JText::_($topleveltxt), 'value', 'text', $disabled);
         if ($preselect && empty($selected) && !$disabled) {
             $selected[] = 0;
         }
         $toplevel = 1;
     } else {
         $toplevel = -KunenaForumCategoryHelper::get($parent)->level;
     }
     foreach ($categories as $category) {
         $disabled = !$category->authorise($action) || !$sections && $category->isSection();
         if ($preselect && empty($selected) && !$disabled) {
             $selected[] = $category->id;
         }
         $options[] = JHtml::_('select.option', $category->id, str_repeat('- ', $category->level + $toplevel) . ' ' . $category->name, 'value', 'text', $disabled);
     }
     $disabled = false;
     foreach ($channels as $category) {
         if ($preselect && empty($selected)) {
             $selected[] = $category->id;
         }
         $options[] = JHtml::_('select.option', $category->id, '+ ' . $category->getParent()->name . ' / ' . $category->name, 'value', 'text', $disabled);
     }
     reset($options);
     if (is_array($attribs)) {
         $attribs = Joomla\Utilities\ArrayHelper::toString($attribs);
     }
     $id = $name;
     if ($idtag) {
         $id = $idtag;
     }
     $id = str_replace('[', '', $id);
     $id = str_replace(']', '', $id);
     $html = '';
     if (!empty($options)) {
         $html .= '<select name="' . $name . '" id="' . $id . '" ' . $attribs . '>';
         $html .= JHtml::_('select.options', $options, $key, $text, $selected, $translate);
         $html .= '</select>';
     }
     return $html;
 }
Exemplo n.º 2
0
 /**
  * Displays a calendar control field based on Twitter Bootstrap 3
  *
  * @param   string $value      The date value
  * @param   string $name       The name of the text field
  * @param   string $id         The id of the text field
  * @param   string $format     The date format
  * @param   mixed  $attributes Additional HTML attributes
  *
  * @return  string  HTML markup for a calendar field
  *
  * @since   1.5
  * @see     http://eonasdan.github.io/bootstrap-datetimepicker/
  */
 public static function calendar($value, $name, $id, $format = 'Y-m-d', array $attributes = array())
 {
     static $done;
     if ($done === null) {
         $done = array();
     }
     $readonly = (!empty($attributes['readonly']) and $attributes['readonly'] === 'readonly');
     $disabled = (!empty($attributes['disabled']) and $attributes['disabled'] === 'disabled');
     if (is_array($attributes)) {
         $attributes['class'] = !empty($attributes['class']) ? $attributes['class'] : 'form-control';
         $attributes['class'] = trim($attributes['class'] . ' hasTooltip');
         $attributes = Joomla\Utilities\ArrayHelper::toString($attributes);
     }
     // Format value when not nulldate ('0000-00-00 00:00:00'), otherwise blank it as it would result in 1970-01-01.
     if ((int) $value && $value !== JFactory::getDbo()->getNullDate()) {
         $date = new DateTime($value, new DateTimeZone('UTC'));
         $inputvalue = $date->format($format);
     } else {
         $inputvalue = '';
     }
     // Load the calendar behavior
     JHtml::_('Prism.ui.bootstrap3Datepicker');
     $languageTag = JFactory::getLanguage()->getTag();
     $locale = substr($languageTag, 0, 2);
     // Only display the triggers once for each control.
     if (!in_array($id, $done, true)) {
         $calendarDateFormat = Prism\Utilities\DateHelper::formatCalendarDate($format);
         $document = JFactory::getDocument();
         $document->addScriptDeclaration('jQuery(document).ready(function($) {
                     jQuery("#' . $id . '_datepicker").datetimepicker({
                         format: "' . $calendarDateFormat . '",
                         locale: "' . \JString::strtolower($locale) . '",
                         allowInputToggle: true
                     });
                 });');
         $done[] = $id;
     }
     // Hide button using inline styles for readonly/disabled fields
     $btn_style = $readonly || $disabled ? ' style="display:none;"' : '';
     return '<div class="input-group date" id="' . $id . '_datepicker">
                 <input type="text" title="' . ($inputvalue ? JHtml::_('date', $value, null, null) : '') . '"
                 name="' . $name . '" id="' . $id . '" value="' . htmlspecialchars($inputvalue, ENT_COMPAT, 'UTF-8') . '" ' . $attributes . ' />
                 <span class="input-group-addon" id="' . $id . '_img">
                     <span class="fa fa-calendar" id="' . $id . '_icon"' . $btn_style . '></span>
                 </span>
             </div>';
 }
 *                             - animation    boolean  Fade in from the top of the page (default = true)
 *                             - footer       string   Optional markup for the modal footer
 *                             - url          string   URL of a resource to be inserted as an <iframe> inside the modal body
 *                             - height       string   height of the <iframe> containing the remote resource
 *                             - width        string   width of the <iframe> containing the remote resource
 *                             - bodyHeight   int      Optional height of the modal body in viewport units (vh)
 *                             - modalWidth   int      Optional width of the modal in viewport units (vh)
 * @param   string  $body      Markup for the modal body. Appended after the <iframe> if the url option is set
 *
 */
$iframeClass = 'iframe';
$bodyHeight = isset($params['bodyHeight']) ? round((int) $params['bodyHeight'], -1) : '';
if ($bodyHeight && $bodyHeight >= 20 && $bodyHeight < 90) {
    $iframeClass .= ' jviewport-height' . $bodyHeight;
}
$iframeAttributes = array('class' => $iframeClass, 'src' => $params['url']);
if (isset($params['title'])) {
    $iframeAttributes['name'] = addslashes($params['title']);
}
if (isset($params['height'])) {
    $iframeAttributes['height'] = $params['height'];
}
if (isset($params['width'])) {
    $iframeAttributes['width'] = $params['width'];
}
?>
<iframe <?php 
echo Joomla\Utilities\ArrayHelper::toString($iframeAttributes);
?>
></iframe>