Esempio n. 1
0
 /**
  * Installs a BlockType that is passed via a btHandle string. The core or override directories are parsed.
  */
 public static function installBlockType($btHandle, $pkg = false)
 {
     $env = Environment::get();
     $pkgHandle = false;
     if (is_object($pkg)) {
         $pkgHandle = $pkg->getPackageHandle();
     }
     $class = static::getBlockTypeMappedClass($btHandle, $pkgHandle);
     $app = Facade::getFacadeApplication();
     $bta = $app->build($class);
     $path = dirname($env->getPath(DIRNAME_BLOCKS . '/' . $btHandle . '/' . FILENAME_BLOCK_DB, $pkgHandle));
     //Attempt to run the subclass methods (install schema from db.xml, etc.)
     $r = $bta->install($path);
     // Prevent the database records being stored in wrong language
     $loc = Localization::getInstance();
     $loc->pushActiveContext('system');
     //Install the block
     $bt = new \Concrete\Core\Entity\Block\BlockType\BlockType();
     $bt->loadFromController($bta);
     if (is_object($pkg)) {
         $bt->setPackageID($pkg->getPackageID());
     }
     $bt->setBlockTypeHandle($btHandle);
     $loc->popActiveContext();
     $em = \ORM::entityManager();
     $em->persist($bt);
     $em->flush();
     if ($bta->getBlockTypeDefaultSet()) {
         $set = Set::getByHandle($bta->getBlockTypeDefaultSet());
         if (is_object($set)) {
             $set->addBlockType($bt);
         }
     }
     return $bt;
 }
Esempio n. 2
0
 /**
  * {@inheritDoc}
  */
 public static function process($assets)
 {
     if ($directory = self::getOutputDirectory()) {
         $relativeDirectory = self::getRelativeOutputDirectory();
         $filename = '';
         $sourceFiles = array();
         for ($i = 0; $i < count($assets); $i++) {
             $asset = $assets[$i];
             $filename .= $asset->getAssetHashKey();
             $sourceFiles[] = $asset->getAssetURL();
         }
         $filename = sha1($filename);
         $app = Facade::getFacadeApplication();
         $ah = $app->make('helper/assets');
         $paths = array();
         foreach ($assets as $asset) {
             $paths[] = $asset->getAssetPath();
         }
         $relativePath = $ah->javascriptPath($paths, array('name' => $filename, 'skipDigest' => true));
         $assetDir = Config::get('concrete.cache.directory');
         $asset = new CssAsset();
         $asset->setAssetURL($relativePath);
         $asset->setAssetPath($assetDir . $relativePath);
         $asset->setCombinedAssetSourceFiles($sourceFiles);
         return array($asset);
     }
     return $assets;
 }
Esempio n. 3
0
 public static function controller($item)
 {
     if ($item instanceof \Page) {
         return $item->getController();
     }
     $controller = '\\Concrete\\Controller\\' . camelcase($item);
     $app = Facade::getFacadeApplication();
     return $app->build($controller);
 }
Esempio n. 4
0
 public function on_start()
 {
     $this->loadDependencies();
     $app = Facade::getFacadeApplication();
     $sp = new PackageServiceProvider($app);
     $sp->register();
     $sp->registerOverrides();
     $sp->registerConfigurations();
     $sp->registerEvents();
     $fp = new FilterProvider($app);
     $fp->register();
     $fp->registerFilters();
 }
Esempio n. 5
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $rc = 0;
     try {
         $info = Facade::getFacadeApplication()->make(Info::class);
         /* @var Info $info */
         $output->writeln('<info># concrete5 Version</info>');
         $output->writeln('Installed - ' . ($info->isInstalled() ? 'Yes' : 'No'));
         $output->writeln($info->getCoreVersions());
         $output->writeln('');
         $output->writeln('<info># Paths</info>');
         $output->writeln('Web root - ' . $info->getWebRootDirectory());
         $output->writeln('Core root - ' . $info->getCoreRootDirectory());
         $output->writeln('');
         $output->writeln('<info># concrete5 Packages</info>');
         $output->writeln($info->getPackages() ?: 'None');
         $output->writeln('');
         $output->writeln('<info># concrete5 Overrides</info>');
         $output->writeln($info->getOverrides() ?: 'None');
         $output->writeln('');
         $output->writeln('<info># concrete5 Cache Settings</info>');
         $output->writeln($info->getCache());
         $output->writeln('');
         $output->writeln('<info># Server API</info>');
         $output->writeln($info->getServerAPI());
         $output->writeln('');
         $output->writeln('<info># PHP Version</info>');
         $output->writeln($info->getPhpVersion());
         $output->writeln('');
         $output->writeln('<info># PHP Extensions</info>');
         $output->writeln($info->getPhpExtensions() === false ? 'Unable to determine' : $info->getPhpExtensions());
         $output->writeln('');
         $output->writeln('<info># PHP Settings</info>');
         $output->writeln($info->getPhpSettings());
     } catch (Exception $x) {
         $output->writeln('<error>' . $x->getMessage() . '</error>');
         $rc = 1;
     }
     return $rc;
 }
Esempio n. 6
0
 public function __construct()
 {
     $loc = Localization::getInstance();
     $loc->pushActiveContext('system');
     try {
         $app = Facade::getFacadeApplication();
         $config = $app->make('config');
         $maxExecutionTime = ini_get('max_execution_time');
         @set_time_limit(5);
         $this->installed = (bool) $app->isInstalled();
         $this->webRootDirectory = DIR_BASE;
         $this->coreRootDirectory = DIR_BASE_CORE;
         $versions = ['Core Version - ' . $config->get('concrete.version')];
         if ($this->installed) {
             $versions[] = 'Version Installed - ' . $config->get('concrete.version_installed');
         }
         $versions[] = 'Database Version - ' . $config->get('concrete.version_db');
         $this->coreVersions = implode("\n", $versions);
         $packages = [];
         if ($this->installed) {
             foreach (PackageList::get()->getPackages() as $p) {
                 if ($p->isPackageInstalled()) {
                     $packages[] = $p->getPackageName() . ' (' . $p->getPackageVersion() . ')';
                 }
             }
         }
         natcasesort($packages);
         $this->packages = implode(', ', $packages);
         $overrides = Environment::get()->getOverrideList();
         if (empty($overrides)) {
             $this->overrides = '';
         } else {
             $this->overrides = implode(', ', $overrides);
         }
         $cache = [sprintf('Block Cache - %s', $config->get('concrete.cache.blocks') ? 'On' : 'Off'), sprintf('Overrides Cache - %s', $config->get('concrete.cache.overrides') ? 'On' : 'Off'), sprintf('Full Page Caching - %s', $config->get('concrete.cache.pages') == 'blocks' ? 'On - If blocks on the particular page allow it.' : ($config->get('concrete.cache.pages') == 'all' ? 'On - In all cases.' : 'Off'))];
         if ($config->get('concrete.cache.full_page_lifetime')) {
             $cache[] = sprintf("Full Page Cache Lifetime - %s", $config->get('concrete.cache.full_page_lifetime') == 'default' ? sprintf('Every %s (default setting).', $app->make('helper/date')->describeInterval($config->get('concrete.cache.lifetime'))) : ($config->get('concrete.cache.full_page_lifetime') == 'forever' ? 'Only when manually removed or the cache is cleared.' : sprintf('Every %s minutes.', $config->get('concrete.cache.full_page_lifetime_value'))));
         }
         $this->cache = implode("\n", $cache);
         $this->serverSoftware = \Request::getInstance()->server->get('SERVER_SOFTWARE', '');
         $this->serverAPI = PHP_SAPI;
         $this->phpVersion = PHP_VERSION;
         if (function_exists('get_loaded_extensions')) {
             $extensions = @get_loaded_extensions();
         } else {
             $extensions = false;
         }
         if (is_array($extensions)) {
             natcasesort($extensions);
             $this->phpExtensions = implode(', ', $extensions);
         } else {
             $this->phpExtensions = false;
         }
         ob_start();
         phpinfo();
         $buffer = ob_get_clean();
         $phpinfo = [];
         if ($app->isRunThroughCommandLineInterface()) {
             $section = null;
             foreach (preg_split('/[\\r\\n]+/', $buffer) as $line) {
                 $chunks = array_map('trim', explode('=>', $line));
                 switch (count($chunks)) {
                     case 1:
                         if ($chunks[0] === '') {
                             continue;
                         }
                         $section = $chunks[0];
                         break;
                     case 2:
                         if ($section !== null) {
                             $phpinfo[$section][$chunks[0]] = $chunks[1];
                         }
                         break;
                     default:
                         if ($section !== null) {
                             $phpinfo[$section][$chunks[0]] = [$chunks[1], $chunks[2]];
                         }
                         break;
                 }
             }
         } else {
             $section = 'phpinfo';
             $phpinfo[$section] = [];
             if (preg_match_all('#(?:<h2>(?:<a name=".*?">)?(.*?)(?:</a>)?</h2>)|(?:<tr(?: class=".*?")?><t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>(?:<t[hd](?: class=".*?")?>(.*?)\\s*</t[hd]>)?)?</tr>)#s', $buffer, $matches, PREG_SET_ORDER)) {
                 foreach ($matches as $match) {
                     if ($match[1] !== null && $match[1] !== '') {
                         $section = $match[1];
                         $phpinfo[$section] = [];
                     } elseif (isset($match[3])) {
                         $phpinfo[$section][$match[2]] = isset($match[4]) ? [$match[3], $match[4]] : $match[3];
                     } else {
                         $phpinfo[$section][] = $match[2];
                     }
                 }
             }
         }
         $phpSettings = ["max_execution_time - {$maxExecutionTime}"];
         foreach ($phpinfo as $name => $section) {
             foreach ($section as $key => $val) {
                 if (preg_match('/.*max_execution_time*/', $key)) {
                     continue;
                 }
                 if (strpos($key, 'limit') === false && strpos($key, 'safe') === false && strpos($key, 'max') === false) {
                     continue;
                 }
                 if (is_array($val)) {
                     $phpSettings[] = "{$key} - {$val[0]}";
                 } elseif (is_string($key)) {
                     $phpSettings[] = "{$key} - {$val}";
                 } else {
                     $phpSettings[] = $val;
                 }
             }
         }
         $this->phpSettings = implode("\n", $phpSettings);
         $loc->popActiveContext();
     } catch (\Exception $x) {
         $loc->popActiveContext();
         throw $x;
     }
 }
Esempio n. 7
0
 /**
  * Boot up
  * Return a response if we're ready to output.
  *
  * @return null|Response
  */
 public function boot()
 {
     $app = $this->app;
     /*
      * ----------------------------------------------------------------------------
      * Bind the IOC container to our facades
      * Completely indebted to Taylor Otwell & Laravel for this.
      * ----------------------------------------------------------------------------
      */
     Facade::setFacadeApplication($app);
     /**
      * ----------------------------------------------------------------------------
      * Load path detection for relative assets, URL and path to home.
      * ----------------------------------------------------------------------------.
      */
     require_once DIR_BASE_CORE . '/bootstrap/paths.php';
     /*
      * ----------------------------------------------------------------------------
      * Add install environment detection
      * ----------------------------------------------------------------------------
      */
     $this->initializeEnvironmentDetection($app);
     /*
      * ----------------------------------------------------------------------------
      * Enable Configuration
      * ----------------------------------------------------------------------------
      */
     $config = $this->initializeConfig($app);
     /*
      * ----------------------------------------------------------------------------
      * Enable Localization
      * ----------------------------------------------------------------------------
      */
     $this->initializeLocalization($app);
     /*
      * ----------------------------------------------------------------------------
      * Finalize paths.
      * ----------------------------------------------------------------------------
      */
     require DIR_BASE_CORE . '/bootstrap/paths_configured.php';
     /*
      * ----------------------------------------------------------------------------
      * Timezone Config
      * ----------------------------------------------------------------------------
      */
     $this->initializeTimezone($config);
     /*
      * ----------------------------------------------------------------------------
      * Setup core classes aliases.
      * ----------------------------------------------------------------------------
      */
     $this->initializeClassAliases($config);
     /*
      * ----------------------------------------------------------------------------
      * Setup the core service groups.
      * ----------------------------------------------------------------------------
      */
     $this->initializeServiceProviders($app, $config);
     /*
      * ----------------------------------------------------------------------------
      * Simple legacy constants like APP_CHARSET
      * ----------------------------------------------------------------------------
      */
     $this->initializeLegacyDefinitions($config, $app);
     /*
      * ----------------------------------------------------------------------------
      * Setup file cache directories. Has to come after we define services
      * because we use the file service.
      * ----------------------------------------------------------------------------
      */
     $app->setupFilesystem();
     /*
      * ----------------------------------------------------------------------------
      * Registries for theme paths, assets, routes and file types.
      * ----------------------------------------------------------------------------
      */
     $this->initializeAssets($config);
     $this->initializeRoutes($config);
     $this->initializeFileTypes($config);
     // If we're not in the CLI SAPI, lets do additional booting for HTTP
     if (!$this->app->isRunThroughCommandLineInterface()) {
         return $this->bootHttpSapi($config, $app);
     }
 }
Esempio n. 8
0
 /**
  * Check if there's some multilingual section.
  *
  * @return bool
  */
 public static function isEnabled()
 {
     $app = Facade::getFacadeApplication();
     $cache = $app->make('cache/request');
     $item = $cache->getItem('multilingual/enabled');
     if (!$item->isMiss()) {
         return $item->get();
     }
     $item->lock();
     $result = false;
     if ($app->isInstalled()) {
         $site = $app->make('site')->getSite();
         if (count($site->getLocales()) > 1) {
             $result = true;
         }
     }
     $cache->save($item->set($result));
     return $result;
 }
Esempio n. 9
0
 public function deleteBlock($forceDelete = false)
 {
     $db = Loader::db();
     if ($this->bID < 1) {
         return false;
     }
     $cID = $this->cID;
     $c = $this->getBlockCollectionObject();
     $cvID = $c->getVersionID();
     $bID = $this->bID;
     $arHandle = $this->arHandle;
     // if this block is located in a master collection, we're going to delete all the instances of the block,
     // regardless
     if ($c instanceof \Concrete\Core\Page\Page && $c->isMasterCollection() && !$this->isAlias() || $forceDelete) {
         // forceDelete is used by the administration console
         // this is an original. We're deleting it, and everything else having to do with it
         $q = "delete from CollectionVersionBlocks where bID = ?";
         $r = $db->query($q, array($bID));
         $q = "delete from BlockPermissionAssignments where bID = ?";
         $r = $db->query($q, array($bID));
         $q = "delete from CollectionVersionBlockStyles where bID = ?";
         $r = $db->query($q, array($bID));
         $q = "delete from CollectionVersionBlocksCacheSettings where bID = ?";
         $r = $db->query($q, array($bID));
     } else {
         $q = "delete from CollectionVersionBlocks where cID = ? and (cvID = ? or cbIncludeAll=1) and bID = ? and arHandle = ?";
         $r = $db->query($q, array($cID, $cvID, $bID, $arHandle));
         // next, we delete the groups instance of this block
         $q = "delete from BlockPermissionAssignments where bID = ? and cvID = ? and cID = ?";
         $r = $db->query($q, array($bID, $cvID, $cID));
         $q = "delete from CollectionVersionBlockStyles where cID = ? and cvID = ? and bID = ? and arHandle = ?";
         $r = $db->query($q, array($cID, $cvID, $bID, $arHandle));
         $q = "delete from CollectionVersionBlocksCacheSettings where cID = ? and cvID = ? and bID = ? and arHandle = ?";
         $r = $db->query($q, array($cID, $cvID, $bID, $arHandle));
     }
     // delete any feature assignments that have been attached to this block to the collection version
     $faIDs = $db->GetCol('select faID from BlockFeatureAssignments where cID = ? and cvID = ? and bID = ?', array($cID, $cvID, $bID));
     foreach ($faIDs as $faID) {
         $fa = FeatureAssignment::getByID($faID, $c);
         $fa->delete();
     }
     //then, we see whether or not this block is aliased to anything else
     $totalBlocks = $db->GetOne('select count(*) from CollectionVersionBlocks where bID = ?', array($bID));
     $totalBlocks += $db->GetOne('select count(*) from btCoreScrapbookDisplay where bOriginalID = ?', array($bID));
     if ($totalBlocks < 1) {
         // this block is not referenced in the system any longer, so we delete the entry in the blocks table, as well as the entries in the corresponding
         // sub-blocks table
         $v = array($this->bID);
         // so, first we delete the block's sub content
         $bt = BlockType::getByID($this->getBlockTypeID());
         if ($bt && method_exists($bt, 'getBlockTypeClass')) {
             $class = $bt->getBlockTypeClass();
             $app = Facade::getFacadeApplication();
             $bc = $app->build($class, [$this]);
             $bc->delete();
         }
         // now that the block's subcontent delete() method has been run, we delete the block from the Blocks table
         $q = "delete from Blocks where bID = ?";
         $r = $db->query($q, $v);
         // Aaaand then we delete all scrapbooked blocks to this entry
         $r = $db->Execute('select cID, cvID, CollectionVersionBlocks.bID, arHandle from CollectionVersionBlocks inner join btCoreScrapbookDisplay on CollectionVersionBlocks.bID = btCoreScrapbookDisplay.bID where bOriginalID = ?', array($bID));
         while ($row = $r->FetchRow()) {
             $c = Page::getByID($row['cID'], $row['cvID']);
             $b = self::getByID($row['bID'], $c, $row['arHandle']);
             $b->delete();
         }
     }
 }
Esempio n. 10
0
 /**
  * Loads controller.
  */
 public function loadController()
 {
     $class = $this->getBlockTypeClass();
     /** @var Controller controller */
     if ($class) {
         $this->controller = Facade::getFacadeApplication()->build($class, [$this]);
     }
 }
Esempio n. 11
0
 public function getAssetCollection(array $assetPaths)
 {
     $app = Facade::getFacadeApplication();
     $factory = $app->make('Assetic\\Factory\\AssetFactory');
     $fsr = $this->app->make('Concrete\\Package\\AssetPipeline\\Src\\Asset\\Filter\\SettingsRepositoryInterface');
     $fm = $factory->getFilterManager();
     $assets = new AssetCollection();
     // Set the filters to he filter manager
     foreach ($fsr->getAllFilterSettings() as $key => $flt) {
         if (!$this->app->bound('assets/filter/' . $key)) {
             throw new Exception(t("Filter not available for key: %s", $key));
         }
         $fm->set($key, $this->app->make('assets/filter/' . $key, $this));
     }
     // Create the asset and push it into the AssetCollection
     // with the filter keys that should be applied to that
     // asset
     $plainAssets = array();
     foreach ($assetPaths as $k => $path) {
         $appliedFilters = array();
         foreach ($fsr->getAllFilterSettings() as $key => $flt) {
             if (!isset($flt['applyTo']) || !$flt['applyTo'] || !is_string($flt['applyTo'])) {
                 continue;
             }
             if (preg_match('#' . str_replace('#', '\\#', $flt['applyTo']) . '#', $path)) {
                 $appliedFilters[] = $key;
             }
         }
         if (count($appliedFilters) > 0) {
             $assets->add($factory->createAsset($path, $appliedFilters));
         } else {
             $plainAssets[] = $path;
         }
     }
     // Add assets that did not go through any filters
     if (count($plainAssets) > 0) {
         $assets->add($factory->createAsset($plainAssets));
     }
     return $assets;
 }
Esempio n. 12
0
 public function rescanThumbnails()
 {
     if ($this->fvType != \Concrete\Core\File\Type\Type::T_IMAGE) {
         return false;
     }
     $app = Facade::getFacadeApplication();
     $imagewidth = $this->getAttribute('width');
     $imageheight = $this->getAttribute('height');
     $types = Type::getVersionList();
     $fr = $this->getFileResource();
     try {
         $mimetype = $fr->getMimeType();
         $imageLibrary = \Image::getFacadeRoot();
         switch ($mimetype) {
             case 'image/svg+xml':
             case 'image/svg-xml':
                 if ($imageLibrary instanceof \Imagine\Gd\Imagine) {
                     try {
                         $imageLibrary = $app->make('image/imagick');
                     } catch (\Exception $x) {
                         return false;
                     }
                 }
                 break;
         }
         $image = $imageLibrary->load($fr->read());
         /* @var \Imagine\Imagick\Image $image */
         if (!$imagewidth) {
             $imagewidth = $image->getSize()->getWidth();
         }
         if (!$imageheight) {
             $imageheight = $image->getSize()->getHeight();
         }
         foreach ($types as $type) {
             // delete the file if it exists
             $this->deleteThumbnail($type);
             // if image is smaller than width, don't create thumbnail
             if ($imagewidth < $type->getWidth()) {
                 continue;
             }
             // if image is the same width as thumbnail, and there's no thumbnail height set,
             // or if a thumbnail height set and the image has a smaller or equal height, don't create thumbnail
             if ($imagewidth == $type->getWidth() && (!$type->getHeight() || $imageheight <= $type->getHeight())) {
                 continue;
             }
             // otherwise file is bigger than thumbnail in some way, proceed to create thumbnail
             $filesystem = $this->getFile()->getFileStorageLocationObject()->getFileSystemObject();
             $height = $type->getHeight();
             if ($height) {
                 $size = new Box($type->getWidth(), $height);
                 $thumbnailMode = ImageInterface::THUMBNAIL_OUTBOUND;
             } else {
                 $size = $image->getSize()->widen($type->getWidth());
                 $thumbnailMode = ImageInterface::THUMBNAIL_INSET;
             }
             $thumbnail = $image->thumbnail($size, $thumbnailMode);
             $thumbnailPath = $type->getFilePath($this);
             $thumbnailOptions = [];
             switch ($mimetype) {
                 case 'image/jpeg':
                     $thumbnailType = 'jpeg';
                     $thumbnailOptions = ['jpeg_quality' => \Config::get('concrete.misc.default_jpeg_image_compression')];
                     break;
                 case 'image/png':
                     $thumbnailType = 'png';
                     break;
                 case 'image/gif':
                     $thumbnailType = 'gif';
                     break;
                 case 'image/xbm':
                     $thumbnailType = 'xbm';
                     break;
                 case 'image/vnd.wap.wbmp':
                     $thumbnailType = 'wbmp';
                     break;
                 default:
                     $thumbnailType = 'png';
                     break;
             }
             $filesystem->write($thumbnailPath, $thumbnail->get($thumbnailType, $thumbnailOptions), ['visibility' => AdapterInterface::VISIBILITY_PUBLIC, 'mimetype' => $mimetype]);
             if ($type->getHandle() == \Config::get('concrete.icons.file_manager_listing.handle')) {
                 $this->fvHasListingThumbnail = true;
             }
             if ($type->getHandle() == \Config::get('concrete.icons.file_manager_detail.handle')) {
                 $this->fvHasDetailThumbnail = true;
             }
             unset($size);
             unset($thumbnail);
             unset($filesystem);
         }
     } catch (\Imagine\Exception\InvalidArgumentException $e) {
         return false;
     } catch (\Imagine\Exception\RuntimeException $e) {
         return false;
     }
 }
Esempio n. 13
0
 /**
  * To be called every time the current locale changes.
  *
  * @param string $locale
  */
 protected function currentLocaleChanged($locale)
 {
     PunicData::setDefaultLocale($locale);
     $app = Facade::getFacadeApplication();
     if ($app->bound('director')) {
         $event = new \Symfony\Component\EventDispatcher\GenericEvent();
         $event->setArgument('locale', $locale);
         $app->make('director')->dispatch('on_locale_load', $event);
     }
 }
Esempio n. 14
0
 /**
  * Returns the controller class for the currently selected captcha library.
  *
  * @return \Concrete\Core\Captcha\Controller
  */
 public function getController()
 {
     $class = overrideable_core_class('Core\\Captcha\\' . camelcase($this->sclHandle) . 'Controller', DIRNAME_CLASSES . '/Captcha/' . camelcase($this->sclHandle) . 'Controller.php', $this->getPackageHandle());
     $app = Facade::getFacadeApplication();
     $cl = $app->make($class);
     return $cl;
 }
Esempio n. 15
0
 /**
  * @return bool|Page
  */
 public function getPreviousCollection()
 {
     $page = false;
     $app = Facade::getFacadeApplication();
     $db = $app->make('database')->connection();
     $cID = 1;
     $currentPage = Page::getCurrentPage();
     while ($cID > 0) {
         switch ($this->orderBy) {
             case 'chrono_desc':
                 $cID = $db->GetOne('select Pages.cID from Pages inner join CollectionVersions cv on Pages.cID = cv.cID where cvIsApproved = 1 and cvDatePublic < ? and cParentID = ?  order by cvDatePublic desc', [$currentPage->getCollectionDatePublic(), $currentPage->getCollectionParentID()]);
                 break;
             case 'chrono_asc':
                 $cID = $db->GetOne('select Pages.cID from Pages inner join CollectionVersions cv on Pages.cID = cv.cID where cvIsApproved = 1 and cvDatePublic > ? and cParentID = ?  order by cvDatePublic asc', [$currentPage->getCollectionDatePublic(), $currentPage->getCollectionParentID()]);
                 break;
             case 'display_desc':
                 $cID = $db->GetOne('select cID from Pages where cDisplayOrder > ? and cParentID = ? order by cDisplayOrder asc', [$currentPage->getCollectionDisplayOrder(), $currentPage->getCollectionParentID()]);
                 break;
             case 'display_asc':
             default:
                 $cID = $db->GetOne('select cID from Pages where cDisplayOrder < ? and cParentID = ? order by cDisplayOrder desc', [$currentPage->getCollectionDisplayOrder(), $currentPage->getCollectionParentID()]);
                 break;
         }
         if ($cID > 0) {
             $page = Page::getByID($cID, 'RECENT');
             $currentPage = $page;
             $cp = new Permissions($page);
             if ($cp->canRead() && $page->getAttribute('exclude_nav') != 1) {
                 break;
             } else {
                 $page = false;
                 //avoid accidentally returning this $page if we're on last loop iteration
             }
         }
     }
     if (!is_object($page) && $this->loopSequence) {
         $c = Page::getCurrentPage();
         $parent = Page::getByID($c->getCollectionParentID(), 'ACTIVE');
         switch ($this->orderBy) {
             case 'chrono_desc':
                 return $parent->getFirstChild('cvDatePublic desc');
                 break;
             case 'chrono_asc':
                 return $parent->getFirstChild('cvDatePublic asc');
                 break;
             case 'display_desc':
                 return $parent->getFirstChild('cDisplayOrder asc');
                 break;
             case 'display_asc':
             default:
                 return $parent->getFirstChild('cDisplayOrder desc');
                 break;
         }
     }
     return $page;
 }
Esempio n. 16
0
 * Instantiate concrete5.
 * ----------------------------------------------------------------------------
 */
/** @var Application $cms */
$cms = (require DIR_APPLICATION . '/bootstrap/start.php');
$cms->instance('app', $cms);
// Bind fully application qualified class names
$cms->instance('Concrete\\Core\\Application\\Application', $cms);
$cms->instance('Illuminate\\Container\\Container', $cms);
/**
 * ----------------------------------------------------------------------------
 * Bind the IOC container to our facades
 * Completely indebted to Taylor Otwell & Laravel for this.
 * ----------------------------------------------------------------------------
 */
Facade::setFacadeApplication($cms);
/**
 * ----------------------------------------------------------------------------
 * Load path detection for relative assets, URL and path to home.
 * ----------------------------------------------------------------------------
 */
require DIR_BASE_CORE . '/bootstrap/paths.php';
/**
 * ----------------------------------------------------------------------------
 * Add install environment detection
 * ----------------------------------------------------------------------------
 */
$db_config = array();
if (file_exists(DIR_APPLICATION . '/config/database.php')) {
    $db_config = (include DIR_APPLICATION . '/config/database.php');
}
Esempio n. 17
0
 public function on_start()
 {
     parent::on_start();
     $this->app = Facade::getFacadeApplication();
     $this->entityManager = $this->app->make('database/orm')->entityManager();
 }
Esempio n. 18
0
 private function clearPublishDates()
 {
     $app = Facade::getFacadeApplication();
     $db = $app->make('database')->connection();
     $q = "update CollectionVersions set cvPublishDate = NULL where cID = ?";
     $db->executeQuery($q, array($this->cID));
 }