/** * Renders the Articles tab * * @param Table[] $rows Articles to render * @param cbPageNav $pageNav Pagination * @param boolean $searching Currently searching * @param string[] $input HTML of input elements * @param UserTable $viewer Viewing user * @param UserTable $user Viewed user * @param stdClass $model The model reference * @param TabTable $tab Current Tab * @param PluginTable $plugin Current Plugin * @return string HTML */ static public function showPreparatyTab( $rows, $pageNav, $searching, $input, $viewer, $user, /** @noinspection PhpUnusedParameterInspection */ $model, $tab, /** @noinspection PhpUnusedParameterInspection */ $plugin ) { global $_CB_framework, $_LANG; $app =& JFactory::getApplication(); $menu = $app->getMenu(); $active = $menu->getActive(); $Itemid = $active->id; $tabPaging = $tab->params->get( 'tab_paging', 1 ); $canSearch = ( $tab->params->get( 'tab_search', 1 ) && ( $searching || $pageNav->total ) ); $canCreate = false; $profileOwner = ( $viewer->get( 'id' ) == $user->get( 'id' ) ); $cbModerator = Application::User( (int) $viewer->get( 'id' ) )->isGlobalModerator(); //$canPublish = ( $cbModerator || ( $profileOwner && ( ! $plugin->params->get( 'hangout_approval', 0 ) ) ) ); if ( $profileOwner ) { if ( $cbModerator ) { $canCreate = true; } elseif ( $user->get( 'id' ) && Application::User( (int) $viewer->get( 'id' ) )->canViewAccessLevel( (int) $plugin->params->get( 'hangout_create_access', 2 ) ) ) { if ( ( ! $blogLimit ) || ( $blogLimit && ( $pageNav->total < $blogLimit ) ) ) { $canCreate = true; } } } $return = '<div class="articlesTab">' . '<form action="' . $_CB_framework->userProfileUrl( $user->id, true, $tab->tabid ) . '" method="post" name="articleForm" id="articleForm" class="articleForm">'; if ( $canCreate ) { $return .= '<div class="' . ( ! $canSearch ? 'col-sm-12' : 'col-sm-8' ) . ' text-left">' . '<button type="button" onclick="location.href=\'' . ($_CB_framework->getCfg( 'live_site' ).'/index.php?option=com_flexicontent&view=item&typeid=2&task=add&Itemid='.$Itemid) . '\';" class="blogsButton blogsButtonNew btn btn-success"><span class="fa fa-plus-circle"></span> ' . $_LANG['New Preparat'] . '</button>' . '</div>'; } if ( $canSearch ) { $return .= '<div class="articlesHeader row" style="margin-bottom: 10px;">' . '<div class="col-sm-offset-8 col-sm-4 text-right">' . '<div class="input-group">' . '<span class="input-group-addon"><span class="fa fa-search"></span></span>' . $input['search'] . '</div>' . '</div>' . '</div>'; } $return .= '<table class="articlesContainer table table-hover table-responsive">' . '<thead>' . '<tr>' . '<th style="width: 50%;" class="text-left">' . $_LANG['Preparat'] . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Category' ) . '</th>' . '<th style="width: 25%;" class="text-left hidden-xs">' . CBTxt::T( 'Created' ) . '</th>' . '<th style="width: 1%;" class="text-left hidden-xs"></th>' . '</tr>' . '</thead>' . '<tbody>'; $attribs = ''; $image = FLEXI_J16GE ? JHTML::image(FLEXI_ICONPATH.'edit.png', JText::_( 'FLEXI_EDIT' ), $attribs) : JHTML::_('image.site', 'edit.png', FLEXI_ICONPATH, NULL, NULL, JText::_( 'FLEXI_EDIT' ), $attribs) ; if ( $rows ) foreach ( $rows as $row ) { $item_url = cbpreparatyModel::getUrl( $row, true, 'article' , $Itemid); //$item_url_edit = cbpreparatyModel::getUrl( $row, true, 'article' , 445); $link = $_CB_framework->getCfg( 'live_site' ). '/' .$item_url .(strstr($item_url, '?') ? '&' : '?'). 'task=edit'; $edit_row = $profileOwner ? '<a href="'.$link.'">'.$image.'</a> ' : ''; $return .= '<tr>' . '<td style="width: 50%;" class="text-left">'.$edit_row.'<a href="' . cbpreparatyModel::getUrl( $row, true, 'article' ) . '">' . $row->get( 'title' ) . '</a></td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . ( $row->get( 'category' ) ? $row->get( 'category_title' ) : CBTxt::T( 'None' ) ) . '</td>' . '<td style="width: 25%;" class="text-left hidden-xs">' . cbFormatDate( $row->get( 'created' ) ) . '</td>'; if ( ( $cbModerator || $profileOwner ) ) { $menuItems = '<ul class="invitesMenuItems dropdown-menu" style="display: block; position: relative; margin: 0;">'; $menuItems .= '<li class="invitesMenuItem"><a href="' . $link . '"><span class="fa fa-edit"></span> ' . CBTxt::T( 'Edit' ) . '</a></li>' . '<li class="invitesMenuItem"><a href="javascript: void(0);" onclick="if ( confirm( \'' . addslashes( CBTxt::T( 'Are you sure you want to delete this Drug?' ) ) . '\' ) ) { location.href = \'' . $_CB_framework->pluginClassUrl( $plugin->element, false, array( 'action' => 'preparaty', 'func' => 'delete', 'id' => (int) $row->get( 'id' ) ) ) . '\'; }"><span class="fa fa-trash-o"></span> ' . CBTxt::T( 'Delete' ) . '</a></li>'; $menuItems .= '</ul>'; $menuAttr = cbTooltip( 1, $menuItems, null, 'auto', null, null, null, 'class="btn btn-default btn-xs" data-cbtooltip-menu="true" data-cbtooltip-classes="qtip-nostyle"' ); $return .= '<td style="width: 1%;" class="text-right">' . '<div class="invitesMenu btn-group">' . '<button type="button"' . $menuAttr . '><span class="fa fa-cog"></span> <span class="fa fa-caret-down"></span></button>' . '</div>' . '</td>'; } else{ $return .= '<td style="width: 1%;" class="text-right"></td>'; } $return .= '</tr>'; } else { $return .= '<tr>' . '<td colspan="3" class="text-left">'; if ( $searching ) { $return .= $_LANG['No preparaty search results found.']; } else { if ( $viewer->id == $user->id ) { $return .= $_LANG['You have no preparaty.']; } else { $return .= $_LANG['This user has no preparaty.']; } } $return .= '</td>' . '</tr>'; } $return .= '</tbody>'; if ( $tabPaging && ( $pageNav->total > $pageNav->limit ) ) { $return .= '<tfoot>' . '<tr>' . '<td colspan="3" class="text-center">' . $pageNav->getListLinks() . '</td>' . '</tr>' . '</tfoot>'; } $return .= '</table>' . $pageNav->getLimitBox( false ) . '</form>' . '</div>'; return $return; }
/** * Generates the HTML to display the user profile tab * * @param \CB\Database\Table\TabTable $tab the tab database entry * @param \CB\Database\Table\UserTable $user the user being displayed * @param int $ui 1 for front-end, 2 for back-end * @return string|boolean Either string HTML for tab content, or false if ErrorMSG generated */ public function getDisplayTab( $tab, $user, $ui ) { global $_CB_framework, $_CB_database, $_LANG; outputCbJs( 1 ); outputCbTemplate( 1 ); cbimport( 'cb.pagination' ); $plugin = cbpreparatyClass::getPlugin(); $model = cbpreparatyClass::getModel(); $viewer = CBuser::getMyUserDataInstance(); cbpreparatyClass::getTemplate( 'tab' ); $limit = (int) $this->params->get( 'tab_limit', 15 ); $limitstart = $_CB_framework->getUserStateFromRequest( 'tab_articles_limitstart{com_comprofiler}', 'tab_articles_limitstart' ); $filterSearch = $_CB_framework->getUserStateFromRequest( 'tab_articles_search{com_comprofiler}', 'tab_articles_search' ); $where = null; if ( isset( $filterSearch ) && ( $filterSearch != '' ) ) { $where .= "\n AND ( a." . $_CB_database->NameQuote( 'title' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " OR a." . $_CB_database->NameQuote( 'introtext' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " OR a." . $_CB_database->NameQuote( 'fulltext' ) . " LIKE " . $_CB_database->Quote( '%' . $_CB_database->getEscaped( $filterSearch, true ) . '%', false ) . " )"; } $searching = ( $where ? true : false ); $total = cbpreparatyModel::getPreparatyTotal( $where, $viewer, $user, $plugin ); if ( $total <= $limitstart ) { $limitstart = 0; } $pageNav = new cbPageNav( $total, $limitstart, $limit ); $pageNav->setInputNamePrefix( 'tab_articles_' ); $rows = cbpreparatyModel::getPreparaty( ( $this->params->get( 'tab_paging', 1 ) ? array( $pageNav->limitstart, $pageNav->limit ) : null ), $where, $viewer, $user, $plugin ); $input = array(); $input['search'] = '<input type="text" name="tab_articles_search" value="' . htmlspecialchars( $filterSearch ) . '" onchange="document.articleForm.submit();" placeholder="' . htmlspecialchars( $_LANG['Search'] ) . '" class="form-control" />'; $tab->params = $this->params; $class = $plugin->params->get( 'general_class', null ); $return = '<div id="cbArticles" class="cbArticles' . ( $class ? ' ' . htmlspecialchars( $class ) : null ) . '">' . '<div id="cbArticlesInner" class="cbArticlesInner">' . HTML_cbpreparatyTab::showPreparatyTab( $rows, $pageNav, $searching, $input, $viewer, $user, $model, $tab, $plugin ) . '</div>' . '</div>'; return $return; }