Beispiel #1
0
 /**
  * Get the package handle (or false if it's a core library).
  *
  * @return string|false
  */
 public function getPackageHandle()
 {
     if (!isset($this->pkgHandle)) {
         $this->pkgHandle = $this->pkgID ? PackageList::getHandle($this->pkgID) : false;
     }
     return $this->pkgHandle;
 }
 public function setLocale($locale)
 {
     if ($locale == 'en_US' && !Config::get('concrete.misc.enable_translate_locale_en_us')) {
         $this->translate = null;
     } else {
         $this->translate = new Translator();
         $this->translate->setLocale($locale);
         $this->translate->setCache(self::getCache());
         // Core language files
         $languageFile = DIR_LANGUAGES . "/{$locale}/LC_MESSAGES/messages.mo";
         if (!is_file($languageFile)) {
             $languageFile = DIR_LANGUAGES_CORE . "/{$locale}/LC_MESSAGES/messages.mo";
             if (!is_file($languageFile)) {
                 $languageFile = '';
             }
         }
         if ($languageFile !== '') {
             $this->translate->addTranslationFile('gettext', $languageFile);
         }
         // Package language files
         if (Config::get('app.bootstrap.packages_loaded') === true) {
             $pkgList = \Concrete\Core\Package\PackageList::get();
             foreach ($pkgList->getPackages() as $pkg) {
                 $pkg->setupPackageLocalization($locale, $this->translate);
             }
             // Site language files
             static::setupSiteLocalization($this->translate);
         }
     }
     PunicData::setDefaultLocale($locale);
     $event = new \Symfony\Component\EventDispatcher\GenericEvent();
     $event->setArgument('locale', $locale);
     Events::dispatch('on_locale_load', $event);
 }
Beispiel #3
0
 public static function getByHandle($ptPublishTargetTypeHandle)
 {
     $db = Loader::db();
     $r = $db->GetRow('select ptPublishTargetTypeID, ptPublishTargetTypeHandle, ptPublishTargetTypeName, pkgID from PageTypePublishTargetTypes where ptPublishTargetTypeHandle = ?', array($ptPublishTargetTypeHandle));
     if (is_array($r) && $r['ptPublishTargetTypeHandle']) {
         $txt = Loader::helper('text');
         $class = overrideable_core_class('Core\\Page\\Type\\PublishTarget\\Type\\' . $txt->camelcase($r['ptPublishTargetTypeHandle']) . 'Type', DIRNAME_CLASSES . '/Page/Type/PublishTarget/Type/' . $txt->camelcase($r['ptPublishTargetTypeHandle']) . '.php', PackageList::getHandle($r['pkgID']));
         $sc = Core::make($class);
         $sc->setPropertiesFromArray($r);
         return $sc;
     }
 }
Beispiel #4
0
 public static function getByHandle($scsHandle)
 {
     $db = Loader::db();
     $r = $db->GetRow('select scsHandle, scsIsActive, pkgID, scsName from SystemContentEditorSnippets where scsHandle = ?', array($scsHandle));
     if (is_array($r) && $r['scsHandle']) {
         $pkgHandle = false;
         if ($r['pkgID']) {
             $pkgHandle = PackageList::getHandle($r['pkgID']);
         }
         $class = overrideable_core_class('Core\\Editor\\' . camelcase($r['scsHandle']) . 'Snippet', DIRNAME_CLASSES . '/Editor/' . camelcase($r['scsHandle']) . 'Snippet.php', $pkgHandle);
         $sc = Core::make($class);
         $sc->setPropertiesFromArray($r);
         return $sc;
     }
 }
 /**
  * {@inheritDoc}
  */
 public function loadTranslations(TranslatorAdapterInterface $translatorAdapter)
 {
     $config = $this->app->make('config');
     if ($config->get('app.bootstrap.packages_loaded') === true) {
         $pkgList = PackageList::get();
         $translator = $translatorAdapter->getTranslator();
         $locale = $translatorAdapter->getLocale();
         foreach ($pkgList->getPackages() as $pkg) {
             $path = $pkg->getPackagePath() . '/' . DIRNAME_LANGUAGES;
             $languageFile = "{$path}/{$locale}/LC_MESSAGES/messages.mo";
             if (is_file($languageFile)) {
                 $translator->addTranslationFile('gettext', $languageFile);
             }
         }
     }
 }
 public static function getByHandle($scsHandle)
 {
     $db = Loader::db();
     $r = $db->GetRow('select scsHandle, scsIsActive, pkgID, scsName from SystemContentEditorSnippets where scsHandle = ?', array($scsHandle));
     if (is_array($r) && $r['scsHandle']) {
         $pkgHandle = false;
         if ($r['pkgID']) {
             $pkgHandle = PackageList::getHandle($r['pkgID']);
         }
         $txt = Loader::helper('text');
         $class = '\\Concrete\\Core\\Editor\\' . $txt->camelcase($r['scsHandle']) . 'Snippet';
         $sc = Core::make($class);
         $sc->setPropertiesFromArray($r);
         return $sc;
     }
 }
 /**
  * Add the c5 specific debug stuff
  */
 protected function addDetails()
 {
     /**
      * General
      */
     $this->addDataTable('Concrete5', array('Version' => APP_VERSION, 'Installed Version' => Config::get('app.version')));
     /**
      * Cache
      */
     $this->addDataTable('Preferences', array('Block Cache' => Config::get('concrete.cache.blocks') ? 'ON' : 'OFF', 'Overrides Cache' => Config::get('concrete.cache.overrides') ? 'ON' : 'OFF', 'Full Page' => Config::get('concrete.cache.pages') ? 'ON' : 'OFF', 'Full Page Lifetime' => Config::get('concrete.cache.full_page_lifetime', 'default')));
     /**
      * Installed Packages
      */
     $pla = PackageList::get();
     $pl = $pla->getPackages();
     $packages = array();
     foreach ($pl as $p) {
         if ($p->isPackageInstalled()) {
             $packages[$p->getPackageName()] = $p->getPackageVersion();
         }
     }
     $this->addDataTable('Installed Packages', $packages);
 }
 public function run()
 {
     $this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>");
     $this->x->addAttribute('version', '1.0');
     // First, attribute categories
     AttributeKeyCategory::exportList($this->x);
     // Features
     Feature::exportList($this->x);
     FeatureCategory::exportList($this->x);
     ConversationEditor::exportList($this->x);
     ConversationRatingType::exportList($this->x);
     // composer
     PageTypePublishTargetType::exportList($this->x);
     PageTypeComposerControlType::exportList($this->x);
     PageType::exportList($this->x);
     // attribute types
     AttributeType::exportList($this->x);
     // then block types
     BlockTypeList::exportList($this->x);
     // now block type sets (including user)
     BlockTypeSet::exportList($this->x);
     // gathering
     GatheringDataSource::exportList($this->x);
     GatheringItemTemplate::exportList($this->x);
     // now attribute keys (including user)
     AttributeKey::exportList($this->x);
     // now attribute keys (including user)
     AttributeSet::exportList($this->x);
     PageTemplate::exportList($this->x);
     // now theme
     PageTheme::exportList($this->x);
     // now packages
     PackageList::export($this->x);
     // permission access entity types
     PermissionAccessEntityType::exportList($this->x);
     // now task permissions
     PermissionKey::exportList($this->x);
     // workflow types
     WorkflowType::exportList($this->x);
     // now jobs
     Job::exportList($this->x);
     // now single pages
     $singlepages = $this->x->addChild("singlepages");
     $db = Loader::db();
     $r = $db->Execute('select cID from Pages where cFilename is not null and cFilename <> "" and cID not in (select cID from Stacks) order by cID asc');
     while ($row = $r->FetchRow()) {
         $pc = Page::getByID($row['cID'], 'RECENT');
         $pc->export($singlepages);
     }
     // now stacks/global areas
     StackList::export($this->x);
     // now content pages
     $pages = $this->x->addChild("pages");
     $db = Loader::db();
     $r = $db->Execute('select Pages.cID from Pages where cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc');
     while ($row = $r->FetchRow()) {
         $pc = Page::getByID($row['cID'], 'RECENT');
         if ($pc->getPageTypeHandle() == STACKS_PAGE_TYPE) {
             continue;
         }
         $pc->export($pages);
     }
     SystemCaptchaLibrary::exportList($this->x);
     \Concrete\Core\Sharing\SocialNetwork\Link::exportList($this->x);
     \Concrete\Core\Page\Feed::exportList($this->x);
     \Concrete\Core\File\Image\Thumbnail\Type\Type::exportList($this->x);
     Config::exportList($this->x);
     Tree::exportList($this->x);
 }
Beispiel #9
0
 /**
  * @param int $akID
  * @return Key|false Returns an attribute key for the matching ID,
  * false if no key exists for the category with the given ID
  */
 public function getAttributeKeyByID($akID)
 {
     $txt = Core::make('helper/text');
     $prefix = $this->pkgID > 0 ? PackageList::getHandle($this->pkgID) : false;
     $akCategoryHandle = $txt->camelcase($this->akCategoryHandle);
     $className = core_class('Core\\Attribute\\Key\\' . $akCategoryHandle . 'Key', $prefix);
     $ak = call_user_func(array($className, 'getByID'), $akID);
     return $ak;
 }
Beispiel #10
0
 public static function getByID($wpID)
 {
     $db = Database::connection();
     $r = $db->fetchAssoc('select WorkflowProgress.*, WorkflowProgressCategories.wpCategoryHandle, WorkflowProgressCategories.pkgID from WorkflowProgress inner join WorkflowProgressCategories on WorkflowProgress.wpCategoryID = WorkflowProgressCategories.wpCategoryID where wpID  = ?', array($wpID));
     if (!is_array($r) || !$r['wpID']) {
         return false;
     }
     $class = '\\Core\\Workflow\\Progress\\' . Core::make('helper/text')->camelcase($r['wpCategoryHandle']) . 'Progress';
     if ($r['pkgID']) {
         $pkgHandle = PackageList::getHandle($r['pkgID']);
     }
     $class = core_class($class, $pkgHandle);
     $wp = Core::make($class);
     $wp->setPropertiesFromArray($r);
     $wp->loadDetails();
     return $wp;
 }
Beispiel #11
0
 public function mergeTranslationsWithPackages(Section $section, Translations $translations)
 {
     foreach (PackageList::get()->getPackages() as $package) {
         /* @var $package \Concrete\Core\Package\Package */
         $baseDir = $package->getPackagePath() . '/' . DIRNAME_LANGUAGES . '/' . $section->getLocale() . '/LC_MESSAGES';
         $poFile = $baseDir . '/messages.po';
         $moFile = $baseDir . '/messages.mo';
         $packageTranslations = null;
         if (is_file($poFile)) {
             $packageTranslations = PoExtractor::fromFile($poFile);
         } elseif (is_file($moFile)) {
             $packageTranslations = MoExtractor::fromFile($moFile);
         }
         if (isset($packageTranslations)) {
             foreach ($translations as $translation) {
                 /* @var $translation \Gettext\Translation */
                 if (!$translation->hasTranslation()) {
                     $packageTranslation = $packageTranslations->find($translation);
                     if ($packageTranslation && $packageTranslation->hasTranslation()) {
                         $translation->mergeWith($packageTranslation);
                     }
                 }
             }
         }
     }
 }
Beispiel #12
0
 /**
  * Return the first existing file path in this order:
  *  - /models/authentication/types/HANDLE
  *  - /packages/PKGHANDLE/authentication/types/HANDLE
  *  - /concrete/models/authentication/types/HANDLE
  *  - /concrete/core/models/authentication/types/HANDLE
  *
  * @param string $_file The filename you want.
  * @return string This will return false if the file is not found.
  */
 protected function mapAuthenticationTypeFilePath($_file)
 {
     $atHandle = $this->getAuthenticationTypeHandle();
     $env = Environment::get();
     $pkgHandle = PackageList::getHandle($this->pkgID);
     $r = $env->getRecord(implode('/', array(DIRNAME_AUTHENTICATION, $atHandle, $_file)), $pkgHandle);
     return $r;
 }
Beispiel #13
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;
     }
 }
Beispiel #14
0
 public function get_environment_info()
 {
     $activeLocale = Localization::activeLocale();
     if ($activeLocale != 'en_US') {
         Localization::changeLocale('en_US');
     }
     $maxExecutionTime = ini_get('max_execution_time');
     set_time_limit(5);
     $environmentMessage = "# concrete5 Version\n" . APP_VERSION . "\n\n";
     $environmentMessage .= "# concrete5 Packages\n";
     $pla = PackageList::get();
     $pl = $pla->getPackages();
     $packages = array();
     foreach ($pl as $p) {
         if ($p->isPackageInstalled()) {
             $packages[] = $p->getPackageName() . ' (' . $p->getPackageVersion() . ')';
         }
     }
     if (count($packages) > 0) {
         natcasesort($packages);
         $environmentMessage .= implode(', ', $packages);
         $environmentMessage .= ".\n";
     } else {
         $environmentMessage .= "None\n";
     }
     $environmentMessage .= "\n";
     // overrides
     $environmentMessage .= "# concrete5 Overrides\n";
     $fh = Loader::helper('file');
     $overrides = array();
     $ovBlocks = $fh->getDirectoryContents(DIR_FILES_BLOCK_TYPES);
     $ovControllers = $fh->getDirectoryContents(DIR_FILES_CONTROLLERS);
     $ovElements = $fh->getDirectoryContents(DIR_FILES_ELEMENTS);
     $ovJobs = $fh->getDirectoryContents(DIR_FILES_JOBS);
     $ovCSS = $fh->getDirectoryContents(DIR_APPLICATION . '/' . DIRNAME_CSS);
     $ovJS = $fh->getDirectoryContents(DIR_APPLICATION . '/' . DIRNAME_JAVASCRIPT);
     $ovLng = $fh->getDirectoryContents(DIR_APPLICATION . '/' . DIRNAME_LANGUAGES);
     $ovMail = $fh->getDirectoryContents(DIR_FILES_EMAIL_TEMPLATES);
     $ovSingle = $fh->getDirectoryContents(DIR_FILES_CONTENT);
     $ovThemes = $fh->getDirectoryContents(DIR_FILES_THEMES);
     $ovTools = $fh->getDirectoryContents(DIR_FILES_TOOLS);
     foreach ($ovBlocks as $ovb) {
         $overrides[] = DIRNAME_BLOCKS . '/' . $ovb;
     }
     foreach ($ovControllers as $ovb) {
         $overrides[] = DIRNAME_CONTROLLERS . '/' . $ovb;
     }
     foreach ($ovElements as $ovb) {
         $overrides[] = DIRNAME_ELEMENTS . '/' . $ovb;
     }
     foreach ($ovJobs as $ovb) {
         $overrides[] = DIRNAME_JOBS . '/' . $ovb;
     }
     foreach ($ovJS as $ovb) {
         $overrides[] = DIRNAME_JAVASCRIPT . '/' . $ovb;
     }
     foreach ($ovCSS as $ovb) {
         $overrides[] = DIRNAME_CSS . '/' . $ovb;
     }
     foreach ($ovLng as $ovb) {
         $overrides[] = DIRNAME_LANGUAGES . '/' . $ovb;
     }
     foreach ($ovMail as $ovb) {
         $overrides[] = DIRNAME_MAIL_TEMPLATES . '/' . $ovb;
     }
     foreach ($ovSingle as $ovb) {
         $overrides[] = DIRNAME_PAGES . '/' . $ovb;
     }
     foreach ($ovThemes as $ovb) {
         $overrides[] = DIRNAME_THEMES . '/' . $ovb;
     }
     foreach ($ovTools as $ovb) {
         $overrides[] = DIRNAME_TOOLS . '/' . $ovb;
     }
     if (count($overrides) > 0) {
         $environmentMessage .= implode(', ', $overrides);
         $environmentMessage .= "\n";
     } else {
         $environmentMessage .= "None\n";
     }
     $environmentMessage .= "\n";
     print $environmentMessage;
     // cache
     $environmentMessage = "# concrete5 Cache Settings\n";
     $environmentMessage .= sprintf("Block Cache - %s\n", Config::get('concrete.cache.blocks') ? 'On' : 'Off');
     $environmentMessage .= sprintf("Overrides Cache - %s\n", Config::get('concrete.cache.overrides') ? 'On' : 'Off');
     $environmentMessage .= sprintf("Full Page Caching - %s\n", 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')) {
         $environmentMessage .= sprintf("Full Page Cache Lifetime - %s\n", Config::get('concrete.cache.full_page_lifetime') == 'default' ? sprintf('Every %s (default setting).', Loader::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'))));
     }
     $environmentMessage .= "\n";
     print $environmentMessage;
     $environmentMessage = "# Server Software\n" . $_SERVER['SERVER_SOFTWARE'] . "\n\n";
     $environmentMessage .= "# Server API\n" . php_sapi_name() . "\n\n";
     $environmentMessage .= "# PHP Version\n" . PHP_VERSION . "\n\n";
     $environmentMessage .= "# PHP Extensions\n";
     if (function_exists('get_loaded_extensions')) {
         $gle = @get_loaded_extensions();
         natcasesort($gle);
         $environmentMessage .= implode(', ', $gle);
         $environmentMessage .= ".\n";
     } else {
         $environmentMessage .= "Unable to determine\n";
     }
     print $environmentMessage;
     ob_start();
     phpinfo();
     $phpinfo = array('phpinfo' => array());
     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', ob_get_clean(), $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             if (strlen($match[1])) {
                 $phpinfo[$match[1]] = array();
             } elseif (isset($match[3])) {
                 $phpinfo[end(array_keys($phpinfo))][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
             } else {
                 $phpinfo[end(array_keys($phpinfo))][] = $match[2];
             }
         }
     }
     $environmentMessage = "\n# PHP Settings\n";
     $environmentMessage .= "max_execution_time - {$maxExecutionTime}\n";
     foreach ($phpinfo as $name => $section) {
         foreach ($section as $key => $val) {
             if (preg_match('/.*max_execution_time*/', $key)) {
                 continue;
             }
             if (!preg_match('/.*limit.*/', $key) && !preg_match('/.*safe.*/', $key) && !preg_match('/.*max.*/', $key)) {
                 continue;
             }
             if (is_array($val)) {
                 $environmentMessage .= "{$key} - {$val['0']}\n";
             } elseif (is_string($key)) {
                 $environmentMessage .= "{$key} - {$val}\n";
             } else {
                 $environmentMessage .= "{$val}\n";
             }
         }
     }
     print $environmentMessage;
     exit;
 }
 /**
  * Run startup and localization events on any installed packages.
  */
 public function setupPackages()
 {
     $pla = \Concrete\Core\Package\PackageList::get();
     $pl = $pla->getPackages();
     $cl = ClassLoader::getInstance();
     foreach ($pl as $p) {
         if ($p->isPackageInstalled()) {
             $pkg = Package::getClass($p->getPackageHandle());
             if (is_object($pkg)) {
                 $cl->registerPackage($pkg);
                 // handle updates
                 if (Config::get('concrete.misc.enable_auto_update_packages')) {
                     $pkgInstalledVersion = $p->getPackageVersion();
                     $pkgFileVersion = $pkg->getPackageVersion();
                     if (version_compare($pkgFileVersion, $pkgInstalledVersion, '>')) {
                         $currentLocale = Localization::activeLocale();
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale('en_US');
                         }
                         $p->upgradeCoreData();
                         $p->upgrade();
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale($currentLocale);
                         }
                     }
                 }
                 $pkg->setupPackageLocalization();
                 if (method_exists($pkg, 'on_start')) {
                     $pkg->on_start();
                 }
             }
         }
     }
 }
Beispiel #16
0
 /**
  * Register package autoloaders. Has to come BEFORE session calls.
  */
 public function setupPackageAutoloaders()
 {
     $pla = \Concrete\Core\Package\PackageList::get();
     $pl = $pla->getPackages();
     $cl = ClassLoader::getInstance();
     /** @var \Package[] $pl */
     foreach ($pl as $p) {
         $p->registerConfigNamespace();
         if ($p->isPackageInstalled()) {
             $pkg = Package::getClass($p->getPackageHandle());
             if (is_object($pkg) && !$pkg instanceof \Concrete\Core\Package\BrokenPackage) {
                 $cl->registerPackage($pkg);
                 $this->packages[] = $pkg;
             }
         }
     }
 }
Beispiel #17
0
 public static function getJobObjByHandle($jHandle = '', $jobData = array())
 {
     $jcl = static::jobClassLocations();
     $pkgHandle = null;
     //check for the job file in the various locations
     $db = Loader::db();
     $pkgID = $db->GetOne('select pkgID from Jobs where jHandle = ?', $jHandle);
     if ($pkgID > 0) {
         $pkgHandle = PackageList::getHandle($pkgID);
         if ($pkgHandle) {
             $jcl[] = DIR_PACKAGES . '/' . $pkgHandle . '/' . DIRNAME_JOBS;
             $jcl[] = DIR_PACKAGES_CORE . '/' . $pkgHandle . '/' . DIRNAME_JOBS;
         }
     }
     foreach ($jcl as $jobClassLocation) {
         //load the file & class, then run the job
         $path = $jobClassLocation . '/' . $jHandle . '.php';
         if (file_exists($path)) {
             $className = static::getClassName($jHandle, $pkgHandle);
             $j = Core::make($className);
             $j->jHandle = $jHandle;
             if (intval($jobData['jID']) > 0) {
                 $j->setPropertiesFromArray($jobData);
             }
             return $j;
         }
     }
     return NULL;
 }
Beispiel #18
0
 /**
  * Run startup and localization events on any installed packages.
  */
 public function setupPackages()
 {
     $pla = \Concrete\Core\Package\PackageList::get();
     $pl = $pla->getPackages();
     $cl = ClassLoader::getInstance();
     /** @var \Package[] $pl */
     foreach ($pl as $p) {
         $p->registerConfigNamespace();
         if ($p->isPackageInstalled()) {
             $pkg = Package::getClass($p->getPackageHandle());
             if (is_object($pkg) && !$pkg instanceof \Concrete\Core\Package\BrokenPackage) {
                 $cl->registerPackage($pkg);
                 // handle updates
                 if (Config::get('concrete.updates.enable_auto_update_packages')) {
                     $pkgInstalledVersion = $p->getPackageVersion();
                     $pkgFileVersion = $pkg->getPackageVersion();
                     if (version_compare($pkgFileVersion, $pkgInstalledVersion, '>')) {
                         $currentLocale = Localization::activeLocale();
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale('en_US');
                         }
                         $p->upgradeCoreData();
                         $p->upgrade();
                         if ($currentLocale != 'en_US') {
                             Localization::changeLocale($currentLocale);
                         }
                     }
                 }
                 $pkg->setupPackageLocalization();
                 if (method_exists($pkg, 'on_start')) {
                     $pkg->on_start();
                 }
             }
         }
     }
     Config::set('app.bootstrap.packages_loaded', true);
 }
Beispiel #19
0
 public function get_environment_info()
 {
     $activeLocale = Localization::activeLocale();
     if ($activeLocale != 'en_US') {
         Localization::changeLocale('en_US');
     }
     $maxExecutionTime = ini_get('max_execution_time');
     set_time_limit(5);
     $environmentMessage = "# concrete5 Version\n";
     $environmentMessage .= "Core Version - " . \Config::get('concrete.version') . "\n";
     $environmentMessage .= "Version Installed - " . \Config::get('concrete.version_installed') . "\n";
     $environmentMessage .= "Database Version - " . \Config::get('concrete.version_db') . "\n\n";
     $environmentMessage .= "# concrete5 Packages\n";
     $pla = PackageList::get();
     $pl = $pla->getPackages();
     $packages = array();
     foreach ($pl as $p) {
         if ($p->isPackageInstalled()) {
             $packages[] = $p->getPackageName() . ' (' . $p->getPackageVersion() . ')';
         }
     }
     if (count($packages) > 0) {
         natcasesort($packages);
         $environmentMessage .= implode(', ', $packages);
         $environmentMessage .= ".\n";
     } else {
         $environmentMessage .= "None\n";
     }
     $environmentMessage .= "\n";
     // overrides
     $environmentMessage .= "# concrete5 Overrides\n";
     $env = Environment::get();
     $overrides = $env->getOverrideList();
     if (count($overrides) > 0) {
         $environmentMessage .= implode(', ', $overrides);
         $environmentMessage .= "\n";
     } else {
         $environmentMessage .= "None\n";
     }
     $environmentMessage .= "\n";
     print $environmentMessage;
     // cache
     $environmentMessage = "# concrete5 Cache Settings\n";
     $environmentMessage .= sprintf("Block Cache - %s\n", Config::get('concrete.cache.blocks') ? 'On' : 'Off');
     $environmentMessage .= sprintf("Overrides Cache - %s\n", Config::get('concrete.cache.overrides') ? 'On' : 'Off');
     $environmentMessage .= sprintf("Full Page Caching - %s\n", 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')) {
         $environmentMessage .= sprintf("Full Page Cache Lifetime - %s\n", Config::get('concrete.cache.full_page_lifetime') == 'default' ? sprintf('Every %s (default setting).', Core::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'))));
     }
     $environmentMessage .= "\n";
     print $environmentMessage;
     $environmentMessage = "# Server Software\n" . $_SERVER['SERVER_SOFTWARE'] . "\n\n";
     $environmentMessage .= "# Server API\n" . php_sapi_name() . "\n\n";
     $environmentMessage .= "# PHP Version\n" . PHP_VERSION . "\n\n";
     $environmentMessage .= "# PHP Extensions\n";
     if (function_exists('get_loaded_extensions')) {
         $gle = @get_loaded_extensions();
         natcasesort($gle);
         $environmentMessage .= implode(', ', $gle);
         $environmentMessage .= ".\n";
     } else {
         $environmentMessage .= "Unable to determine\n";
     }
     print $environmentMessage;
     ob_start();
     phpinfo();
     $section = 'phpinfo';
     $phpinfo = array($section => array());
     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', ob_get_clean(), $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             if (strlen($match[1])) {
                 $section = $match[1];
                 $phpinfo[$section] = array();
             } elseif (isset($match[3])) {
                 $phpinfo[$section][$match[2]] = isset($match[4]) ? array($match[3], $match[4]) : $match[3];
             } else {
                 $phpinfo[$section][] = $match[2];
             }
         }
     }
     $environmentMessage = "\n# PHP Settings\n";
     $environmentMessage .= "max_execution_time - {$maxExecutionTime}\n";
     foreach ($phpinfo as $name => $section) {
         foreach ($section as $key => $val) {
             if (preg_match('/.*max_execution_time*/', $key)) {
                 continue;
             }
             if (!preg_match('/.*limit.*/', $key) && !preg_match('/.*safe.*/', $key) && !preg_match('/.*max.*/', $key)) {
                 continue;
             }
             if (is_array($val)) {
                 $environmentMessage .= "{$key} - {$val['0']}\n";
             } elseif (is_string($key)) {
                 $environmentMessage .= "{$key} - {$val}\n";
             } else {
                 $environmentMessage .= "{$val}\n";
             }
         }
     }
     print $environmentMessage;
     exit;
 }
 /**
  * @return Package
  */
 public function install()
 {
     $cl = \Concrete\Core\Foundation\ClassLoader::getInstance();
     $cl->registerPackage($this);
     PackageList::refreshCache();
     $db = Loader::db();
     $dh = Loader::helper('date');
     $v = array($this->getPackageName(), $this->getPackageDescription(), $this->getPackageVersion(), $this->getPackageHandle(), 1, $dh->getOverridableNow());
     $db->query("insert into Packages (pkgName, pkgDescription, pkgVersion, pkgHandle, pkgIsInstalled, pkgDateInstalled) values (?, ?, ?, ?, ?, ?)", $v);
     $pkg = Package::getByID($db->Insert_ID());
     Package::installDB($pkg->getPackagePath() . '/' . FILENAME_PACKAGE_DB);
     $env = Environment::get();
     $env->clearOverrideCache();
     return $pkg;
 }
 protected function computeView()
 {
     $bFilename = $this->bFilename;
     $obj = $this->obj;
     // if we've passed in "templates/" as the first part, we strip that off.
     if (strpos($bFilename, 'templates/') === 0) {
         $bFilename = substr($bFilename, 10);
     }
     // The filename might be a directory name with .php-appended (BlockView does that), strip it.
     $bFilenameWithoutDotPhp = $bFilename;
     if (substr($bFilename, -4) === ".php") {
         $bFilenameWithoutDotPhp = substr($bFilename, 0, strlen($bFilename) - 4);
     }
     if ($bFilename) {
         if (is_file(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) {
             $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
             $bv = new BlockView($obj);
             $this->baseURL = $bv->getBlockURL();
             $this->basePath = $bv->getBlockPath($this->render);
         } else {
             if (is_file(DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) {
                 $template = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
                 $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle();
                 $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle();
             } else {
                 if (is_dir(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) {
                     $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename . '/' . $this->render;
                     $this->basePath = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
                     $this->baseURL = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
                 } else {
                     if (is_dir(DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) {
                         $template = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename . '/' . $this->render;
                         $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
                         $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
                     } else {
                         if ($bFilename !== $bFilenameWithoutDotPhp) {
                             if (is_dir(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp)) {
                                 $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp . '/' . $this->render;
                                 $this->basePath = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp;
                                 $this->baseURL = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp;
                             } else {
                                 if (is_dir(DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp)) {
                                     $template = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp . '/' . $this->render;
                                     $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp;
                                     $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilenameWithoutDotPhp;
                                 }
                             }
                         }
                     }
                 }
             }
         }
         // we check all installed packages
         if (!isset($template)) {
             $pl = PackageList::get();
             $packages = $pl->getPackages();
             foreach ($packages as $pkg) {
                 $d = '';
                 if (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle())) {
                     $d = DIR_PACKAGES . '/' . $pkg->getPackageHandle();
                 } else {
                     if (is_dir(DIR_PACKAGES_CORE . '/' . $pkg->getPackageHandle())) {
                         $d = DIR_PACKAGES_CORE . '/' . $pkg->getPackageHandle();
                     }
                 }
                 if ($d != '') {
                     $baseStub = is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle()) ? DIR_REL . '/' . DIRNAME_PACKAGES . '/' . $pkg->getPackageHandle() : ASSETS_URL . '/' . DIRNAME_PACKAGES . '/' . $pkg->getPackageHandle();
                     if (is_file($d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . $bFilename)) {
                         $template = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . $bFilename;
                         $this->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle();
                         $this->basePath = DIR_FILES_BLOCK_TYPES_CORE . '/' . $obj->getBlockTypeHandle();
                     } else {
                         if (is_file($d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) {
                             $template = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
                             $this->baseURL = $baseStub . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle();
                             $this->basePath = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle();
                         } else {
                             if (is_dir($d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename)) {
                                 $template = $d . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename . '/' . $this->render;
                                 $this->baseURL = $baseStub . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename;
                             }
                         }
                     }
                 }
                 if ($this->baseURL != '') {
                     continue;
                 }
             }
         }
     } else {
         if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '.php')) {
             $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '.php';
             $bv = new BlockView($obj);
             $this->baseURL = $bv->getBlockURL();
             $this->basePath = $bv->getBlockPath($this->render);
         } else {
             if (file_exists(DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . $this->render)) {
                 $template = DIR_FILES_BLOCK_TYPES . '/' . $obj->getBlockTypeHandle() . '/' . $this->render;
                 $this->baseURL = REL_DIR_APPLICATION . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle();
             }
         }
     }
     if (!isset($template)) {
         $bv = new BlockView($obj);
         $template = $bv->getBlockPath($this->render) . '/' . $this->render;
         $this->baseURL = $bv->getBlockURL($this->render);
     }
     if ($this->basePath == '') {
         $this->basePath = dirname($template);
     }
     $this->template = $template;
 }
Beispiel #22
0
 /**
  * Gets the custom templates available for the current BlockType
  *
  * @return TemplateFile[]
  */
 function getBlockTypeCustomTemplates()
 {
     $btHandle = $this->getBlockTypeHandle();
     $fh = Loader::helper('file');
     $files = array();
     $dir = DIR_FILES_BLOCK_TYPES . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES;
     if (is_dir($dir)) {
         $files = array_merge($files, $fh->getDirectoryContents($dir));
     }
     // NOW, we check to see if this btHandle has any custom templates that have been installed as separate packages
     foreach (PackageList::get()->getPackages() as $pkg) {
         $dir = (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle()) ? DIR_PACKAGES : DIR_PACKAGES_CORE) . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_BLOCKS . '/' . $btHandle . '/' . DIRNAME_BLOCK_TEMPLATES;
         if (is_dir($dir)) {
             $files = array_merge($files, $fh->getDirectoryContents($dir));
         }
     }
     $dir = DIR_FILES_BLOCK_TYPES_CORE . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES;
     if (is_dir($dir)) {
         $files = array_merge($files, $fh->getDirectoryContents($dir));
     }
     $templates = array();
     foreach (array_unique($files) as $file) {
         $templates[] = new TemplateFile($this, $file);
     }
     return TemplateFile::sortTemplateFileList($templates);
 }
Beispiel #23
0
 /**
  * Installs the package info row and installs the database. Packages installing additional content should override this method, call the parent method,
  * and use the resulting package object for further installs.
  * @return Package
  */
 public function install()
 {
     PackageList::refreshCache();
     $db = Database::getActiveConnection();
     $dh = Core::make('helper/date');
     $v = array($this->getPackageName(), $this->getPackageDescription(), $this->getPackageVersion(), $this->getPackageHandle(), 1, $dh->getOverridableNow());
     $db->query("INSERT INTO Packages (pkgName, pkgDescription, pkgVersion, pkgHandle, pkgIsInstalled, pkgDateInstalled) VALUES (?, ?, ?, ?, ?, ?)", $v);
     $pkg = Package::getByID($db->lastInsertId());
     ClassLoader::getInstance()->registerPackage($pkg);
     $pkg->installDatabase();
     $env = Environment::get();
     $env->clearOverrideCache();
     Localization::clearCache();
     return $pkg;
 }
Beispiel #24
0
 public function getPackageHandle()
 {
     return \Concrete\Core\Package\PackageList::getHandle($this->pkgID);
 }
Beispiel #25
0
 /**
  * Installs the package info row and installs the database. Packages installing additional content should override this method, call the parent method,
  * and use the resulting package object for further installs.
  *
  * @return Package
  */
 public function install()
 {
     PackageList::refreshCache();
     $em = \Database::connection()->getEntityManager();
     $package = new \Concrete\Core\Entity\Package();
     $package->setPackageName($this->getPackageName());
     $package->setPackageDescription($this->getPackageDescription());
     $package->setPackageVersion($this->getPackageVersion());
     $package->setPackageHandle($this->getPackageHandle());
     $em->persist($package);
     $em->flush();
     $this->installDatabase();
     $env = \Environment::get();
     $env->clearOverrideCache();
     \Localization::clearCache();
     return $package;
 }
 public function getPackageHandle()
 {
     return PackageList::getHandle($this->pkgID);
 }
 public function inc($file, $args = array())
 {
     extract($args);
     if (!isset($obj)) {
         $obj = $this->getPageTypeComposerControlDraftValue();
         if (!is_object($obj)) {
             $obj = $this->getBlockTypeObject();
         }
     }
     $controller = $this->getController($obj);
     extract($controller->getSets());
     extract($controller->getHelperObjects());
     $label = $this->getPageTypeComposerFormLayoutSetControlObject()->getPageTypeComposerControlDisplayLabel();
     $env = Environment::get();
     $pkg = false;
     if ($obj->getPackageID() > 0) {
         $pkg = Package::getByID($obj->getPackageID());
     }
     $view = $this;
     $r = $env->getRecord(DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . $file, $pkg);
     if ($r->exists()) {
         include $r->file;
     } else {
         foreach (PackageList::get()->getPackages() as $pkg) {
             $include = (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle()) ? DIR_PACKAGES : DIR_PACKAGES_CORE) . '/' . $pkg->getPackageHandle() . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . $file;
             if (file_exists($include)) {
                 include $include;
             }
         }
     }
 }