Ejemplo n.º 1
0
	public function create($ptID, $parentID = false) {
		$pagetype = PageType::getByID(Loader::helper('security')->sanitizeInt($ptID));
        if ($parentID) {
            $parent = ConcretePage::getByID($parentID);
        }
		if (is_object($pagetype)) {
            $proceed = false;
            if (is_object($parent) && !$parent->isError()) {
                $pp = new Permissions($parent);
                $proceed = $pp->canAddSubCollection($pagetype);
            } else {
                $ptp = new Permissions($pagetype);
                $proceed = $ptp->canAddPageType();
                if (isset($parent)) {
                    unset($parent);
                }
            }
            if ($proceed) {
				$pt = $pagetype->getPageTypeDefaultPageTemplateObject();
				$d = $pagetype->createDraft($pt);
                if (is_object($parent)) {
                    $d->setPageDraftTargetParentPageID($parent->getCollectionID());
                }
				return Redirect::url(\Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=' . $d->getCollectionID() . '&ctask=check-out-first&' . Loader::helper('validation/token')->getParameter());
			}
		}
	}
 /** Executes the job.
  * @throws \Exception Throws an exception in case of errors.
  *
  * @return string Returns a string describing the job result in case of success.
  */
 public function run()
 {
     Cache::disableAll();
     try {
         $instances = array('navigation' => Core::make('helper/navigation'), 'dashboard' => Core::make('helper/concrete/dashboard'), 'view_page' => PermissionKey::getByHandle('view_page'), 'guestGroup' => Group::getByID(GUEST_GROUP_ID), 'now' => new DateTime('now'), 'ak_exclude_sitemapxml' => CollectionAttributeKey::getByHandle('exclude_sitemapxml'), 'ak_sitemap_changefreq' => CollectionAttributeKey::getByHandle('sitemap_changefreq'), 'ak_sitemap_priority' => CollectionAttributeKey::getByHandle('sitemap_priority'));
         $instances['guestGroupAE'] = array(GroupPermissionAccessEntity::getOrCreate($instances['guestGroup']));
         if (\Core::make('multilingual/detector')->isEnabled()) {
             $instances['multilingualSections'] = MultilingualSection::getList();
         } else {
             $instances['multilingualSections'] = array();
         }
         $xml = '<?xml version="1.0" encoding="' . APP_CHARSET . '"?>';
         $xml .= '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"';
         if ($instances['multilingualSections']) {
             $xml .= ' xmlns:x="http://www.w3.org/1999/xhtml"';
         }
         $xml .= ' />';
         $xmlDoc = new SimpleXMLElement($xml);
         $rs = Database::get()->query('SELECT cID FROM Pages');
         while ($row = $rs->FetchRow()) {
             self::addPage($xmlDoc, intval($row['cID']), $instances);
         }
         $rs->Close();
         $event = new \Symfony\Component\EventDispatcher\GenericEvent();
         $event->setArgument('xmlDoc', $xmlDoc);
         Events::dispatch('on_sitemap_xml_ready', $event);
         $dom = dom_import_simplexml($xmlDoc)->ownerDocument;
         $dom->formatOutput = true;
         $addedPages = count($xmlDoc->url);
         $relName = ltrim(Config::get('concrete.sitemap_xml.file'), '\\/');
         $osName = rtrim(DIR_BASE, '\\/') . '/' . $relName;
         $urlName = rtrim(\Core::getApplicationURL(), '\\/') . '/' . $relName;
         if (!file_exists($osName)) {
             @touch($osName);
         }
         if (!is_writable($osName)) {
             throw new \Exception(t('The file %s is not writable', $osName));
         }
         if (!($hFile = @fopen($osName, 'w'))) {
             throw new \Exception(t('Cannot open file %s', $osName));
         }
         if (!@fwrite($hFile, $dom->saveXML())) {
             throw new \Exception(t('Error writing to file %s', $osName));
         }
         @fflush($hFile);
         @fclose($hFile);
         unset($hFile);
         return t('%1$s file saved (%2$d pages).', sprintf('<a href="%s" target="_blank">%s</a>', $urlName, preg_replace('/^https?:\\/\\//i', '', $urlName)), $addedPages);
     } catch (\Exception $x) {
         if (isset($hFile) && $hFile) {
             @fflush($hFile);
             @ftruncate($hFile, 0);
             @fclose($hFile);
             $hFile = null;
         }
         throw $x;
     }
 }
Ejemplo n.º 3
0
 public function getPublicURLToFile($file)
 {
     $rel = $this->getRelativePathToFile($file);
     if (strpos($rel, '://')) {
         return $rel;
     }
     $url = \Core::getApplicationURL(true);
     $url = $url->setPath($rel);
     return trim((string) $url, '/');
 }
Ejemplo n.º 4
0
                            <?php 
            echo $form->text('collection_handle', $cobj->getCollectionHandle(), array('title' => $cID, 'class' => 'collectionHandle'));
            ?>
                            <?php 
            Page::rescanCollectionPath($cID);
            $path = $cobj->getCollectionPath();
            $tokens = explode('/', $path);
            $lastkey = array_pop(array_keys($tokens));
            $tokens[$lastkey] = '<strong class="collectionPath">' . $tokens[$lastkey] . '</strong>';
            $untokens = implode('/', $tokens);
            ?>
<a class="help-inline url-path" href="<?php 
            echo $nh->getLinkToCollection($cobj);
            ?>
" target="_blank"><?php 
            echo Core::getApplicationURL() . $untokens;
            ?>
</a><?php 
            ?>
                        </div>
                        <?php 
        }
        ?>
                        <div class="form-group submit-changes">
                            <form id="seoForm<?php 
        echo $cID;
        ?>
" action="<?php 
        echo View::url('/dashboard/system/seo/page_data/', 'saveRecord');
        ?>
" method="post" class="pageForm">
Ejemplo n.º 5
0
 public function contentsFrom()
 {
     \Core::forgetInstance('url/canonical');
     return array(array('<a href="{CCM:CID_3}">Super Cool!</a>', '<a href="' . \Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '/awesome/all-right">Super Cool!</a>'));
 }
Ejemplo n.º 6
0
 /**
  * Gets the icon for a page (also fires the on_page_get_icon event).
  *
  * @return string $icon Path to the icon
  */
 public function getCollectionIcon()
 {
     // returns a fully qualified image link for this page's icon, either based on its collection type or if icon.png appears in its view directory
     $icon = '';
     $pe = new Event($this);
     Events::dispatch('on_page_get_icon', $pe);
     if ($icon) {
         return $icon;
     }
     if (\Core::make('multilingual/detector')->isEnabled()) {
         $icon = \Concrete\Core\Multilingual\Service\UserInterface\Flag::getDashboardSitemapIconSRC($this);
     }
     if ($this->isGeneratedCollection()) {
         if ($this->getPackageID() > 0) {
             if (is_dir(DIR_PACKAGES . '/' . $this->getPackageHandle())) {
                 $dirp = DIR_PACKAGES;
                 $url = \Core::getApplicationURL();
             } else {
                 $dirp = DIR_PACKAGES_CORE;
                 $url = ASSETS_URL;
             }
             $file = $dirp . '/' . $this->getPackageHandle() . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON;
             if (file_exists($file)) {
                 $icon = $url . '/' . DIRNAME_PACKAGES . '/' . $this->getPackageHandle() . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON;
             }
         } elseif (file_exists(DIR_FILES_CONTENT . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON)) {
             $icon = \Core::getApplicationURL() . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON;
         } elseif (file_exists(DIR_FILES_CONTENT_REQUIRED . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON)) {
             $icon = ASSETS_URL . '/' . DIRNAME_PAGES . $this->getCollectionPath() . '/' . FILENAME_PAGE_ICON;
         }
     } else {
     }
     return $icon;
 }
Ejemplo n.º 7
0
    ?>
    <div class="form-group">
        <span>
            <?php 
    echo t('Sign in with a community account');
    ?>
        </span>
        <hr>
    </div>
    <div class="form-group">
        <a href="<?php 
    echo \URL::to('/ccm/system/authentication/oauth2/community/attempt_auth');
    ?>
" class="btn btn-primary btn-community btn-block">
            <img src="<?php 
    echo Core::getApplicationURL();
    ?>
/concrete/images/logo.png" class="concrete5-icon"></i>
            <?php 
    echo t('Log in with concrete5.org');
    ?>
        </a>
    </div>
    <div class="form-group">
        <p><?php 
    echo t('Join the concrete5.org community to setup multiple websites, shop for extensions, and get support.');
    ?>
</p>
    </div>
    <?php 
}
Ejemplo n.º 8
0
                    exit;
                    break;
                }
            }
            break;
        case 'approve-recent':
            if ($cp->canApprovePageVersions()) {
                $u = new User();
                $pkr = new \Concrete\Core\Workflow\Request\ApprovePageRequest();
                $pkr->setRequestedPage($c);
                $v = CollectionVersion::get($c, "RECENT");
                $pkr->setRequestedVersionID($v->getVersionID());
                $pkr->setRequesterUserID($u->getUserID());
                $u->unloadCollectionEdit($c);
                $response = $pkr->trigger();
                header('Location: ' . \Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=' . $c->getCollectionID() . $step);
                exit;
            }
            break;
    }
}
if (isset($_REQUEST['ptask']) && $_REQUEST['ptask'] && $valt->validate()) {
    // piles !
    switch ($_REQUEST['ptask']) {
        case 'delete_content':
            //personal scrapbook
            if ($_REQUEST['pcID'] > 0) {
                $pc = PileContent::get($_REQUEST['pcID']);
                $p = $pc->getPile();
                if ($p->isMyPile()) {
                    $pc->delete();
Ejemplo n.º 9
0
<?php $u = new User(); ?>
<script type="text/javascript">
<?php
	echo("var CCM_DISPATCHER_FILENAME = '" . DIR_REL . '/' . DISPATCHER_FILENAME . "';\r");
	echo("var CCM_CID = ".($cID?$cID:0).";\r");
	if (isset($isEditMode)) {
		echo("var CCM_EDIT_MODE = {$isEditMode};\r");
	}
	if (isset($isEditMode)) {
		echo("var CCM_ARRANGE_MODE = {$isArrangeMode};\r");
	}
?>
var CCM_IMAGE_PATH = "<?php echo ASSETS_URL_IMAGES?>";
var CCM_TOOLS_PATH = "<?php echo REL_DIR_FILES_TOOLS_REQUIRED?>";
var CCM_APPLICATION_URL = "<?php echo \Core::getApplicationURL()?>";
var CCM_REL = "<?php echo \Core::getApplicationRelativePath()?>";

</script>

<? if (isset($scc) && is_object($scc)) { ?>
    <style type="text/css">
        <? print $scc->getValue();?>
    </style>
<? } ?>

<?php

$v = View::getInstance();

if (Config::get('concrete.user.profiles_enabled') && $u->isRegistered()) {
 /**
  * Given the current update object, sends information to concrete5.org to determine updatability
  * @return \Concrete\Core\Updater\ApplicationUpdateDiagnostic
  */
 public function getDiagnosticObject()
 {
     $request = new Request();
     $request->setUri(Config::get('concrete.updates.services.inspect_update'));
     $request->setMethod('POST');
     $request->getPost()->set('current_version', Config::get('concrete.version_installed'));
     $request->getPost()->set('requested_version', $this->getVersion());
     $request->getPost()->set('site_url', (string) \Core::getApplicationURL());
     $mi = Marketplace::getInstance();
     if ($mi->isConnected() && !$mi->hasConnectionError()) {
         $config = \Core::make('config/database');
         $request->getPost()->set('marketplace_token', $config->get('concrete.marketplace.token'));
         $list = Package::getInstalledList();
         $packages = array();
         foreach ($list as $pkg) {
             $packages[] = array('version' => $pkg->getPackageVersion(), 'handle' => $pkg->getPackageHandle());
         }
         $request->getPost()->set('packages', $packages);
     }
     $overrides = id(Environment::get())->getOverrideList();
     $request->getPost()->set('overrides', $overrides);
     $client = new Client();
     $client->setMethod('POST');
     $response = $client->send($request);
     $body = $response->getBody();
     $diagnostic = DiagnosticFactory::getFromJSON($body);
     return $diagnostic;
 }
Ejemplo n.º 11
0
 /**
  * Takes a chunk of content containing abstracted link references,
  * and expands them to urls suitable for the rich text editor.
  */
 public static function translateFromEditMode($text)
 {
     $text = preg_replace(array('/{CCM:BASE_URL}/i'), array(\Core::getApplicationURL()), $text);
     //page links...
     $text = preg_replace('/{CCM:CID_([0-9]+)}/i', \Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=\\1', $text);
     //images...
     $dom = new HtmlDomParser();
     $r = $dom->str_get_html($text, true, true, DEFAULT_TARGET_CHARSET, false);
     if (is_object($r)) {
         foreach ($r->find('concrete-picture') as $picture) {
             $fID = $picture->fid;
             $attrString = "";
             foreach ($picture->attr as $attr => $val) {
                 if (!in_array($attr, self::$blackListImgAttributes)) {
                     $attrString .= "{$attr}=\"{$val}\" ";
                 }
             }
             $picture->outertext = '<img src="' . URL::to('/download_file', 'view_inline', $fID) . '" ' . $attrString . '/>';
         }
         $text = (string) $r->restore_noise($r);
     }
     // now we add in support for the links
     $text = preg_replace_callback('/{CCM:FID_([0-9]+)}/i', function ($matches) {
         $fID = $matches[1];
         if ($fID > 0) {
             return URL::to('/download_file', 'view_inline', $fID);
         }
     }, $text);
     //file downloads...
     $text = preg_replace_callback('/{CCM:FID_DL_([0-9]+)}/i', function ($matches) {
         $fID = $matches[1];
         if ($fID > 0) {
             return URL::to('/download_file', 'view', $fID);
         }
     }, $text);
     return $text;
 }
Ejemplo n.º 12
0
</title>
<?php 
$canonical_link = $c->getCollectionLink(true);
echo new \Concrete\Core\Html\Object\HeadLink($canonical_link, 'canonical');
?>
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
<script type="application/ld+json">
<?php 
if (is_object($c)) {
    /** @var \Concrete\Core\Localization\Service\Date $date */
    $date = Core::make('helper/date');
    /** @var \Concrete\Core\Utility\Service\Text $text */
    $text = Core::make('helper/text');
    /** @var \Concrete\Core\Page\Theme\Theme $theme */
    $theme = \Concrete\Core\Page\Theme\Theme::getByHandle('amp');
    $theme_url = Core::getApplicationURL() . $theme->getThemeURL();
    $theme_path = DIR_BASE . $theme->getThemeURL();
    // We can set a headline 3 ways:
    // 1. It comes through programmatically as $pageDescription.
    // 2. It comes from meta description
    // 3. It comes from getCollectionDescription()
    if (!isset($pageDescription) || !$pageDescription) {
        // we aren't getting it dynamically.
        $pageDescription = $c->getCollectionAttributeValue('meta_description');
        if (!$pageDescription) {
            $pageDescription = $c->getCollectionDescription();
        }
    }
    /** @var \Concrete\Core\User\UserInfo $author */
    $author = Core::make('Concrete\\Core\\User\\UserInfoFactory')->getByID($c->getCollectionUserID());
    /** @see https://developers.google.com/search/docs/data-types/articles */
Ejemplo n.º 13
0
 /**
  * Takes a chunk of content containing abstracted link references,
  * and expands them to urls suitable for the rich text editor.
  */
 public static function translateFromEditMode($text)
 {
     $app = \Core::make('app');
     //page links...
     $text = preg_replace('/{CCM:CID_([0-9]+)}/i', \Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=\\1', $text);
     //images...
     $dom = new HtmlDomParser();
     $r = $dom->str_get_html($text);
     if (is_object($r)) {
         foreach ($r->find('concrete-picture') as $picture) {
             $fID = $picture->fid;
             $alt = $picture->alt;
             $style = $picture->style;
             $picture->outertext = '<img src="' . URL::to('/download_file', 'view_inline', $fID) . '" alt="' . $alt . '" style="' . $style . '" />';
         }
         $text = (string) $r;
     }
     //file downloads...
     $text = preg_replace_callback('/{CCM:FID_DL_([0-9]+)}/i', function ($matches) {
         $fID = $matches[1];
         if ($fID > 0) {
             return URL::to('/download_file', 'view', $fID);
         }
     }, $text);
     return $text;
 }
Ejemplo n.º 14
0
 public function getMarketplacePurchaseFrame($mp, $width = '100%', $height = '530')
 {
     $tp = new TaskPermission();
     if ($tp->canInstallPackages()) {
         if (!is_object($mp)) {
             return '<div class="alert-message block-message error">' . t('Unable to get information about this product.') . '</div>';
         }
         if ($this->isConnected()) {
             $url = Config::get('concrete.urls.concrete5_secure') . Config::get('concrete.urls.paths.marketplace.checkout');
             $csiURL = urlencode(\Core::getApplicationURL());
             $csiBaseURL = urlencode(\Core::getApplicationURL());
             $csToken = $this->getSiteToken();
             $url = $url . '/' . $mp->getProductBlockID() . '?ts=' . time() . '&csiBaseURL=' . $csiBaseURL . '&csiURL=' . $csiURL . '&csToken=' . $csToken;
         }
         $time = time();
         $ifr = '<script type="text/javascript">
             window.addEventListener("message", function(e) {
                 jQuery.fn.dialog.hideLoader();
                 if (e.data == "loading") {
                     jQuery.fn.dialog.showLoader();
                 } else {
                     var eh = e.data;
                     eh = parseInt(eh) + 100;
                     $("#ccm-marketplace-frame-' . $time . '").attr("height", eh);
                 }
                 });
             </script>';
         $ifr .= '<iframe class="ccm-marketplace-frame" id="ccm-marketplace-frame-' . $time . '" frameborder="0" width="' . $width . '" height="' . $height . '" src="' . $url . '"></iframe>';
         return $ifr;
     } else {
         return '<div class="ccm-error">' . t('You do not have permission to connect this site to the marketplace.') . '</div>';
     }
 }
Ejemplo n.º 15
0
 public function new_page()
 {
     if ($this->validateAction()) {
         $c = $this->page;
         $e = Core::make('helper/validation/error');
         $pt = $c->getPageTypeObject();
         if (is_object($pt)) {
             $ptp = new \Permissions($pt);
             if (!$ptp->canAddPageType()) {
                 $e->add(t('You do not have permission to create new pages of this type.'));
             }
         }
         $r = new PageEditVersionResponse();
         $r->setError($e);
         if (!$e->has()) {
             $c->loadVersionObject($_REQUEST['cvID']);
             $nc = $c->cloneVersion(t('New Page Created From Version'));
             $v = $nc->getVersionObject();
             $drafts = Page::getByPath(Config::get('concrete.paths.drafts'));
             $nc = $c->duplicate($drafts);
             $nc->deactivate();
             $nc->move($drafts);
             // now we delete all but the new version
             $vls = new VersionList($nc);
             $vls->setItemsPerPage(-1);
             $vArray = $vls->getPage();
             for ($i = 1; $i < count($vArray); $i++) {
                 $cv = $vArray[$i];
                 $cv->delete();
             }
             // now, we delete the version we duped on the current page, since we don't need it anymore.
             $v->delete();
             // finally, we redirect the user to the new drafts page in composer mode.
             $r->setPage($nc);
             $r->setRedirectURL(\Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '?cID=' . $nc->getCollectionID() . '&ctask=check-out-first&' . Loader::helper('validation/token')->getParameter());
         }
         $r->outputJSON();
     }
 }
Ejemplo n.º 16
0
<?php

defined('C5_EXECUTE') or die("Access Denied.");
$ih = Loader::helper('concrete/ui');
echo Loader::helper('concrete/dashboard')->getDashboardPaneHeaderWrapper(t('Single Pages'), false);
?>
	<div class="clearfix">
		<h4><?php 
echo t('Add Single Page');
?>
</h4>
		<?php 
if (Config::get('concrete.seo.url_rewriting')) {
    $base = Core::getApplicationURL();
} else {
    $base = Core::getApplicationURL() . '/' . DISPATCHER_FILENAME;
}
?>
		<form class="form-inline" method="post" id="add_static_page_form" action="<?php 
echo $view->url('/dashboard/pages/single');
?>
">
			<?php 
echo $this->controller->token->output('add_single_page');
?>
            <div class="form-group">
                <div class="input-group">
                    <div class="input-group-addon"><?php 
echo $base;
?>
/</div>
Ejemplo n.º 17
0
                        .css({ width: '100%', height: '100%' })
                        .attr('src', '<?php 
echo DIR_REL;
?>
/concrete/images/login_fade.png'))
                    .fadeIn();
            }, 0);


            <?php 
if (Config::get('concrete.white_label.background_image') !== 'none') {
    ?>
            $(function () {
                var shown = false, info;
                $.getJSON('<?php 
    echo Core::getApplicationURL() . '/' . DISPATCHER_FILENAME . '/tools/required/dashboard/get_image_data';
    ?>
', { image: '<?php 
    echo $image;
    ?>
' }, function (data) {
                    if (shown) {
                        $('div.background-credit').fadeIn().children().attr('href', data.link).text(data.author.join());
                    } else {
                        info = data;
                    }
                });
                $(window).on('backstretch.show', function() {
                    shown = true;

                    if (info) {
Ejemplo n.º 18
0
    foreach ($proxyHeaders as $key => $value) {
        Request::setTrustedHeaderName($key, $value);
    }
}
if ($trustedProxiesIps = $config->get('concrete.security.trusted_proxies.ips')) {
    Request::setTrustedProxies($trustedProxiesIps);
}
/**
 * ----------------------------------------------------------------------------
 * Legacy Definitions
 * ----------------------------------------------------------------------------
 */
define('APP_VERSION', $config->get('concrete.version'));
define('APP_CHARSET', $config->get('concrete.charset'));
try {
    define('BASE_URL', \Core::getApplicationURL());
} catch (\Exception $x) {
    echo $x->getMessage();
    die(1);
}
define('DIR_REL', $cms['app_relative_path']);
/**
 * ----------------------------------------------------------------------------
 * Setup file cache directories. Has to come after we define services
 * because we use the file service.
 * ----------------------------------------------------------------------------
 */
$cms->setupFilesystem();
/**
 * ----------------------------------------------------------------------------
 * Registries for theme paths, assets, routes and file types.
Ejemplo n.º 19
0
 protected static function getRemotePackageObject($method, $identifier)
 {
     $fh = Loader::helper('file');
     // Retrieve the URL contents
     $dbConfig = \Core::make('config/database');
     $csToken = $dbConfig->get('concrete.marketplace.token');
     $csiURL = urlencode(\Core::getApplicationURL());
     $url = Config::get('concrete.urls.concrete5') . Config::get('concrete.urls.paths.marketplace.item_information');
     $url .= "?" . $method . "=" . $identifier . "&csToken={$csToken}&csiURL=" . $csiURL . "&csiVersion=" . APP_VERSION;
     $json = $fh->getContents($url);
     try {
         // Parse the returned XML file
         $obj = @Loader::helper('json')->decode($json);
         if (is_object($obj)) {
             $mi = new RemoteItem();
             $mi->setPropertiesFromJSONObject($obj);
             if ($mi->getMarketplaceItemID() > 0) {
                 return $mi;
             }
         }
     } catch (Exception $e) {
         throw new Exception(t('Unable to connect to marketplace to retrieve item'));
     }
 }