Exemplo n.º 1
0
    /**
     * Generate Group Page Preview
     *
     * @param    $page   Group page object
     * @return   void
     */
    public static function generatePreview($page, $version = 0, $contentOnly = false)
    {
        // get groups
        $gidNumber = $page->get('gidNumber');
        $group = \Hubzero\User\Group::getInstance($gidNumber);
        //get config
        $config = Component::params('com_groups');
        // load page version
        $content = $page->version($version)->content('parsed');
        // create new group document helper
        $groupDocument = new Document();
        // strip out scripts & php tags if not super group
        if (!$group->isSuperGroup()) {
            $content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
            $content = preg_replace('/<\\?[\\s\\S]*?\\?>/', '', $content);
        }
        // are we allowed to display group modules
        if (!$group->isSuperGroup() && !$config->get('page_modules', 0)) {
            $groupDocument->set('allowed_tags', array());
        }
        // set group doc needed props
        // parse and render content
        $groupDocument->set('group', $group)->set('page', $page)->set('document', $content)->parse()->render();
        // get doc content
        $content = $groupDocument->output();
        // only parse php if Super Group
        if ($group->isSuperGroup()) {
            // run as closure to ensure no $this scope
            $eval = function () use($content) {
                ob_start();
                unset($this);
                eval("?>{$content}<?php ");
                $content = ob_get_clean();
                return $content;
            };
            $content = $eval();
        }
        // do we want to retun only content?
        if ($contentOnly) {
            return $content;
        }
        // get group css
        $pageCss = View::getPageCss($group);
        $css = '';
        foreach ($pageCss as $p) {
            $p = rtrim(Request::root(), '/') . '/' . ltrim($p, '/');
            $css .= '<link rel="stylesheet" href="' . $p . '" />';
        }
        // output html
        $html = '<!DOCTYPE html>
				<html>
					<head>
						<title>' . $group->get('description') . '</title>
						' . $css . '
						<style>#system-debug { display: none !important; }</style>
					</head>
					<body class="group-page-preview">
						' . $content . '
					</body>
				</html>';
        // return html
        return $html;
    }
Exemplo n.º 2
0
 /**
  * Edit Module
  *
  * @return void
  */
 public function editTask()
 {
     //set to edit layout
     $this->view->setLayout('edit');
     // get request vars
     $moduleid = Request::getInt('moduleid', 0);
     // get the category object
     $this->view->module = new Module($moduleid);
     // are we passing a module object
     if ($this->module) {
         $this->view->module = $this->module;
     }
     // get a list of all pages for creating module menu
     $pageArchive = Page\Archive::getInstance();
     $this->view->pages = $pageArchive->pages('list', array('gidNumber' => $this->group->get('gidNumber'), 'state' => array(0, 1), 'orderby' => 'lft asc'));
     // get a list of all pages for creating module menu
     $moduleArchive = Module\Archive::getInstance();
     $this->view->order = $moduleArchive->modules('list', array('gidNumber' => $this->group->get('gidNumber'), 'position' => $this->view->module->get('position'), 'state' => array(0, 1), 'orderby' => 'ordering'));
     // get stylesheets for editor
     $this->view->stylesheets = Helpers\View::getPageCss($this->group);
     // build the title
     $this->_buildTitle();
     // build pathway
     $this->_buildPathway();
     // get view notifications
     $this->view->notifications = $this->getNotifications() ? $this->getNotifications() : array();
     $this->view->group = $this->group;
     //display layout
     $this->view->display();
 }
Exemplo n.º 3
0
    /**
     * Preview Group Module
     *
     * @return void
     */
    public function previewTask()
    {
        // make sure we are approvers
        if (!Helpers\Pages::isPageApprover()) {
            App::redirect(Route::url('index.php?option=' . $this->_option . '&controller=' . $this->_controller . '&gid=' . $this->gid, false), Lang::txt('COM_GROUPS_MODULES_AUTHORIZED_APPROVERS_ONLY'), 'error');
            return;
        }
        // get reqest vars
        $moduleid = Request::getInt('moduleid', 0, 'get');
        // page object
        $module = new Module($moduleid);
        // make sure page belongs to this group
        if (!$module->belongsToGroup($this->group)) {
            App::abort(403, Lang::txt('COM_GROUPS_MODULES_NOT_AUTHORIZED'));
        }
        // get first module menu's page id
        $pageid = $module->menu()->first()->get('pageid');
        // check if pageid 0
        if ($pageid == 0) {
            // get a list of all pages
            $pageArchive = Page\Archive::getInstance();
            $pages = $pageArchive->pages('list', array('gidNumber' => $this->group->get('gidNumber'), 'state' => array(1), 'orderby' => 'ordering'));
            // get first page
            $pageid = $pages->first()->get('id');
        }
        // load page
        $page = new Page($pageid);
        // load page version
        $content = $page->version()->content('parsed');
        // create new group document helper
        $groupDocument = new Helpers\Document();
        // strip out scripts & php tags if not super group
        if (!$this->group->isSuperGroup()) {
            $content = preg_replace('#<script(.*?)>(.*?)</script>#is', '', $content);
            $content = preg_replace('/<\\?[\\s\\S]*?\\?>/', '', $content);
        }
        // are we allowed to display group modules
        if (!$this->group->isSuperGroup() && !$this->config->get('page_modules', 0)) {
            $groupDocument->set('allowed_tags', array());
        }
        // set group doc needed props
        // parse and render content
        $groupDocument->set('group', $this->group)->set('page', $page)->set('document', $content)->set('allMods', true)->parse()->render();
        // get doc content
        $content = $groupDocument->output();
        // only parse php if Super Group
        if ($this->group->isSuperGroup()) {
            // run as closure to ensure no $this scope
            $eval = function () use($content) {
                ob_start();
                unset($this);
                eval("?> {$content} <?php ");
                $content = ob_get_clean();
                return $content;
            };
            $content = $eval();
        }
        // get group css
        $pageCss = Helpers\View::getPageCss($this->group);
        $css = '';
        foreach ($pageCss as $p) {
            $css .= '<link rel="stylesheet" href="' . $p . '" />';
        }
        // output html
        $html = '<!DOCTYPE html>
				<html>
					<head>
						<title>' . $this->group->get('description') . '</title>
						' . $css . '
					</head>
					<body>
						' . $content . '
					</body>
				</html>';
        //echo content and exit
        echo $html;
        exit;
    }
Exemplo n.º 4
0
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 * THE SOFTWARE.
 *
 * HUBzero is a registered trademark of Purdue University.
 *
 * @package   hubzero-cms
 * @author    Shawn Rice <*****@*****.**>
 * @copyright Copyright 2005-2015 HUBzero Foundation, LLC.
 * @license   http://opensource.org/licenses/MIT MIT
 */
// No direct access
defined('_HZEXEC_') or die;
$editPageUrl = 'index.php?option=com_groups&cn=' . $this->group->get('cn') . '&controller=pages&task=edit&pageid=' . $this->page->get('id');
// add page stylesheets
$stylesheets = \Components\Groups\Helpers\View::getPageCss($this->group);
foreach ($stylesheets as $stylesheet) {
    Document::addStylesheet($stylesheet);
}
include_once Component::path('com_wiki') . DS . 'helpers' . DS . 'differenceengine.php';
// add styles & scripts
$this->css()->js()->js('jquery.cycle2', 'system');
?>
<header id="content-header">
	<h2><?php 
echo Lang::txt('COM_GROUPS_PAGES_VERSIONS_FOR_PAGE', $this->page->get('title'));
?>
</h2>

	<div id="content-header-extra">
		<ul id="useroptions">