/** * Get the EntityManager(Metadata)Provider * * @return \Concrete\Core\Database\EntityManager\Provider\DefaultPackageProvider|\Concrete\Core\Package\Package */ public function getEntityManagerProvider() { if ($this->pkg instanceof ProviderInterface) { $provider = $this->pkg; } elseif ($this->pkg instanceof ProviderAggregateInterface) { $provider = $this->pkg->getEntityManagerProvider(); } else { $provider = new DefaultPackageProvider($this->app, $this->pkg); } return $provider; }
/** * Removes any existing pages, files, stacks, block and page types and installs content from the package. * * @param $options */ public function swapContent(Package $package, $options) { if ($this->validateClearSiteContents($options)) { \Core::make('cache/request')->disable(); $pl = new PageList(); $pages = $pl->getResults(); foreach ($pages as $c) { $c->delete(); } $fl = new FileList(); $files = $fl->getResults(); foreach ($files as $f) { $f->delete(); } // clear stacks $sl = new StackList(); foreach ($sl->get() as $c) { $c->delete(); } $home = \Page::getByID(HOME_CID); $blocks = $home->getBlocks(); foreach ($blocks as $b) { $b->deleteBlock(); } $pageTypes = Type::getList(); foreach ($pageTypes as $ct) { $ct->delete(); } // Set the page type of the home page to 0, because // if it has a type the type will be gone since we just // deleted it $home = Page::getByID(HOME_CID); $home->setPageType(null); // now we add in any files that this package has if (is_dir($package->getPackagePath() . '/content_files')) { $ch = new ContentImporter(); $computeThumbnails = true; if ($package->contentProvidesFileThumbnails()) { $computeThumbnails = false; } $ch->importFiles($package->getPackagePath() . '/content_files', $computeThumbnails); } // now we parse the content.xml if it exists. $ci = new ContentImporter(); $ci->importContentFile($package->getPackagePath() . '/content.xml'); \Core::make('cache/request')->enable(); } }
public function uninstall() { parent::uninstall(); //Remove our table data $db = Loader::db(); $db->execute("DROP TABLE pkgNewsletterEmails"); }
/** * return \GetText\Translations $translations; */ public function extractTranslatableSiteStrings() { $translations = new Translations(); $translations->insert('SiteName', Config::get('concrete.site')); $phpParser = new \C5TL\Parser\Php(); $blockTemplatesParser = new \C5TL\Parser\BlockTemplates(); $themesPresetsParser = new \C5TL\Parser\ThemePresets(); $processApplication = array(DIRNAME_BLOCKS => array($phpParser, $blockTemplatesParser), DIRNAME_ELEMENTS => array($phpParser), DIRNAME_CONTROLLERS => array($phpParser), DIRNAME_MAIL_TEMPLATES => array($phpParser), DIRNAME_PAGE_TYPES => array($phpParser), DIRNAME_PAGES => array($phpParser), DIRNAME_THEMES => array($phpParser, $themesPresetsParser, $blockTemplatesParser), DIRNAME_VIEWS => array($phpParser)); foreach ($processApplication as $dirname => $parsers) { if (is_dir(DIR_APPLICATION . '/' . $dirname)) { foreach ($parsers as $parser) { /* @var $parser \C5TL\Parser */ $fullDirname = DIR_APPLICATION . '/' . $dirname; if (is_dir($fullDirname)) { $parser->parseDirectory($fullDirname, DIRNAME_APPLICATION . '/' . $dirname, $translations); } } } } if (is_dir(DIR_PACKAGES)) { $packages = Package::getInstalledList(); foreach ($packages as $package) { $fullDirname = DIR_PACKAGES . '/' . $package->getPackageHandle(); $phpParser->parseDirectory($fullDirname, DIRNAME_PACKAGES . '/' . $dirname, $translations); } } // Now, we grab dynamic content that's part of our site that we translate dynamically $dynamicTranslations = $this->getDynamicTranslations(); $translations->mergeWith($dynamicTranslations); return $translations; }
public function refresh_entities() { if ($this->token->validate("refresh_entities")) { if ($this->isPost()) { $em = ORM::entityManager(); $config = $em->getConfiguration(); if (is_object($cache = $config->getMetadataCacheImpl())) { $cache->flushAll(); } try { $packages = Package::getInstalledList(); foreach ($packages as $package) { $package->installEntitiesDatabase(); } $dbm = Core::make('database/structure', array($em)); $dbm->destroyProxyClasses('ApplicationSrc'); if ($dbm->hasEntities()) { $dbm->generateProxyClasses(); $dbm->installDatabase(); } $this->redirect('/dashboard/system/environment/entities', 'entities_refreshed'); } catch (\Doctrine\Common\Persistence\Mapping\MappingException $e) { $drv = $em->getConfiguration()->getMetadataDriverImpl(); $this->error->add(t("The application specific entities directory is missing. Please create it first at: %s.", array_shift($drv->getPaths()))); } catch (\Exception $e) { $this->error->add($e->getMessage()); } } } }
protected function installLegacyDatabaseFile(AttributeType $type) { $r = $this->environment->getRecord(DIRNAME_ATTRIBUTES . DIRECTORY_SEPARATOR . $type->getAttributeTypeHandle() . DIRECTORY_SEPARATOR . FILENAME_ATTRIBUTE_DB, $type->getPackageHandle()); if ($r->exists()) { \Concrete\Core\Package\Package::installDB($r->file); } }
public function on_start() { parent::on_start(); $this->entityManager = Package::getByHandle('migration_tool')->getEntityManager(); ini_set('memory_limit', -1); set_time_limit(0); }
public function view() { $error = \Core::make('helper/validation/error'); $r = $this->item->download(); if ($r != false) { if (is_array($r)) { $errors = Package::mapError($r); foreach ($errors as $e) { $error->add($e); } } else { $error->add($r); } } if (!$error->has()) { $tests = Package::testForInstall($this->item->getHandle()); if (is_array($tests)) { $results = Package::mapError($tests); foreach ($results as $te) { $error->add($te); } } else { $p = Package::getClass($this->item->getHandle()); try { $p->install(); } catch (\Exception $e) { $error->add($e->getMessage()); } } } $this->set('error', $error); $this->set('mri', $this->item); }
public function install() { $pkg = parent::install(); $theme = PageTheme::add('nukiuchi_theme', $pkg); $page = Single::add('/blog', $pkg); $page->setTheme($theme); }
public function install() { if (!extension_loaded('newrelic')) { throw new \Exception(t('The newrelic php extension must be installed as a prerequisite. See %sHow to Setup%s', '<a href="http://www.concrete5.org/marketplace/addons/new-relic-apm/how-to-setup/">', '</a>')); } parent::install(); }
public function install() { $pkg = parent::install(); $bt = BlockType::getByHandle('text_list'); if (!is_object($bt)) { $bt = BlockType::installBlockType('text_list', $pkg); } }
public function install() { $fs = new Filesystem(); if (!$fs->exists(__DIR__ . '/vendor/autoload.php')) { throw new Exception(t("You need to install the composer packages for this add-on before installation!")); } $pkg = parent::install(); }
public function install() { $pkg = parent::install(); \Loader::model('attribute/categories/collection'); $col = AttributeKeyCategory::getByHandle('collection'); $at = AttributeType::add('icon_selector', t('Icon Selector'), $pkg); $col->associateAttributeKeyType($at); }
public function __construct($pkgHandle, Application $application) { $this->pkgHandle = $pkgHandle; $this->pkgVersion = '0.0'; $this->pkgName = t('Unknown Package'); $this->pkgDescription = t('Broken package (handle %s).', $pkgHandle); parent::__construct($application); }
public function uninstall() { $paypal = PaymentMethod::getByHandle('paypal_express'); if (is_object($paypal)) { $paypal->delete(); } parent::uninstall(); }
public static function get($pkgIsInstalled = 1) { $pkgList = CacheLocal::getEntry('pkgList', $pkgIsInstalled); if ($pkgList != false) { return $pkgList; } $db = Loader::db(); $r = $db->query("select pkgID, pkgName, pkgIsInstalled, pkgDescription, pkgVersion, pkgHandle, pkgDateInstalled from Packages where pkgIsInstalled = ? order by pkgID asc", array($pkgIsInstalled)); $list = new static(); while ($row = $r->fetchRow()) { $pkg = new Package(); $pkg->setPropertiesFromArray($row); $list->add($pkg); } CacheLocal::set('pkgList', $pkgIsInstalled, $list); return $list; }
public function install() { $pkg = parent::install(); \Loader::model('attribute/categories/collection'); $col = AttributeKeyCategory::getByHandle('collection'); //Install attribute and attach to the Colletion Category $gallery = AttributeType::add('mixed_gallery', t('Mixed Gallery'), $pkg); $col->associateAttributeKeyType($gallery); }
public function upgrade() { parent::upgrade(); $bt = BlockType::getByHandle('code_snippet'); $btSet = BlockTypeSet::getByHandle('basic'); if (is_object($bt) && is_object($btSet)) { $btSet->addBlockType($bt); } }
public function import(\SimpleXMLElement $sx) { if (isset($sx->packages)) { foreach ($sx->packages->package as $p) { $pkg = Package::getClass((string) $p['handle']); if (!$pkg->isPackageInstalled()) { $pkg->install(); } } } }
public function install() { $pkg = parent::install(); //BlockType::installBlockTypeFromPackage('Mailer', $pkg); Job::installByPackage('process_xmailer', $pkg); SinglePage::add('/dashboard/xmailer', $pkg); SinglePage::add('/dashboard/xmailer/mailboxes', $pkg); SinglePage::add('/dashboard/xmailer/mailboxes/user', $pkg); SinglePage::add('/dashboard/xmailer/mailboxes/group', $pkg); SinglePage::add('/dashboard/xmailer/settings', $pkg); }
public function install($data = array()) { $pkg = parent::install(); // Set Theme // check for active themes $active_theme = PageTheme::getSiteTheme(); // strcmp($active_theme->getThemeHandle(), $themeHandle) == 0 if (is_object($active_theme) && $active_theme->getThemeHandle() !== 'elemental') { // Theme::setThemeHandle($themeHandle); // $pt = PageTheme::getByID($pThemeID); $pt = PageTheme::getByHandle('elemental'); $pt->applyToSite(); } }
public function install() { $pkg = parent::install(); //Add dashboard page $sp = SinglePage::add('/dashboard/open_graph_tags_lite', $pkg); if (is_object($sp)) { $sp->update(array('cName' => t('Open Graph Tags Lite'), 'cDescription' => t('Auto insert Open Graph Tags (OGP) into HEAD tag'))); } $sp = SinglePage::add('/dashboard/open_graph_tags_lite/settings', $pkg); if (is_object($sp)) { $sp->update(array('cName' => t('Open Graph Tags Settings'), 'cDescription' => '')); } //Add og:image attribute $cak = CollectionAttributeKey::getByHandle('og_image'); if (!is_object($cak)) { $at = AttributeType::getByHandle('image_file'); CollectionAttributeKey::add($at, array('akHandle' => 'og_image', 'akName' => t('og:image'))); } }
/** * return \GetText\Translations $translations;. */ public function extractTranslatableSiteStrings() { $app = Application::getFacadeApplication(); $translations = new Translations(); $translations->insert('SiteName', $app->make('site')->getSite()->getSiteName()); $fh = $app->make('helper/file'); C5TLOptions::setTemporaryDirectory($fh->getTemporaryDirectory()); $phpParser = new C5TLParserPhp(); $blockTemplatesParser = new C5TLParserBlockTemplates(); $themesPresetsParser = new C5TLParserThemePresets(); $configFilesParser = new C5TLParserConfigFiles(); $configFilesParser->parseDirectory(DIR_BASE, ''); $processApplication = [DIRNAME_BLOCKS => [$phpParser, $blockTemplatesParser], DIRNAME_ELEMENTS => [$phpParser], DIRNAME_CONTROLLERS => [$phpParser], DIRNAME_MAIL_TEMPLATES => [$phpParser], DIRNAME_PAGE_TYPES => [$phpParser], DIRNAME_PAGES => [$phpParser], DIRNAME_THEMES => [$phpParser, $themesPresetsParser, $blockTemplatesParser], DIRNAME_VIEWS => [$phpParser]]; foreach ($processApplication as $dirname => $parsers) { if (is_dir(DIR_APPLICATION . '/' . $dirname)) { foreach ($parsers as $parser) { /* @var $parser \C5TL\Parser */ $fullDirname = DIR_APPLICATION . '/' . $dirname; if (is_dir($fullDirname)) { $parser->parseDirectory($fullDirname, DIRNAME_APPLICATION . '/' . $dirname, $translations); } } } } if (is_dir(DIR_PACKAGES)) { $packages = Package::getInstalledList(); foreach ($packages as $package) { $fullDirname = DIR_PACKAGES . '/' . $package->getPackageHandle(); $phpParser->parseDirectory($fullDirname, DIRNAME_PACKAGES . '/' . $dirname, $translations); } } // Now, we grab dynamic content that's part of our site that we translate dynamically $dynamicTranslations = $this->getDynamicTranslations(); $translations->mergeWith($dynamicTranslations); return $translations; }
public function uninstall(Package $p) { $p->uninstall(); $config = $this->entityManager->getConfiguration(); $cache = $config->getMetadataCacheImpl(); $cache->flushAll(); }
public function install() { $pkg = parent::install(); BlockType::installBlockTypeFromPackage('mixed_content', $pkg); }
public function getPackageObject() { return Package::getByID($this->pkgID); }
protected static function install($dir, $pThemeHandle, $pkgID) { $result = null; if (is_dir($dir)) { $pkg = null; if ($pkgID) { $pkg = \Concrete\Core\Package\Package::getByID($pkgID); } $db = Loader::db(); $cnt = $db->getOne('select count(pThemeID) from PageThemes where pThemeHandle = ?', [$pThemeHandle]); if ($cnt > 0) { throw new \Exception(static::E_THEME_INSTALLED); } $loc = Localization::getInstance(); $loc->pushActiveContext('system'); try { $res = static::getThemeNameAndDescription($dir, $pThemeHandle, is_object($pkg) ? $pkg->getPackageHandle() : ''); } catch (\Exception $x) { $loc->popActiveContext(); throw $x; } $loc->popActiveContext(); if (strlen($res->pError) === 0) { $pThemeName = $res->pThemeName; $pThemeDescription = $res->pThemeDescription; $db->query('insert into PageThemes (pThemeHandle, pThemeName, pThemeDescription, pkgID) values (?, ?, ?, ?)', [$pThemeHandle, $pThemeName, $pThemeDescription, $pkgID]); $env = Environment::get(); $env->clearOverrideCache(); $pt = static::getByID($db->Insert_ID()); $pt->updateThemeCustomClass(); $result = $pt; } } return $result; }
public function install() { $pkg = parent::install(); Theme::add('scooptherapy', $pkg); }
public function install_database() { $db = Database::get(); $num = $db->GetCol("show tables"); if (count($num) > 0) { throw new \Exception(t('There are already %s tables in this database. concrete5 must be installed in an empty database.', count($num))); } $installDirectory = DIR_BASE_CORE . '/config'; try { $em = \ORM::entityManager('core'); $dbm = Core::make('database/structure', $em); $dbm->generateProxyClasses(); Package::installDB($installDirectory . '/db.xml'); $this->indexAdditionalDatabaseFields(); $configuration = new Configuration(); $version = $configuration->getVersion(Config::get('concrete.version_db')); $version->markMigrated(); } catch (\Exception $e) { throw new \Exception(t('Unable to install database: %s', $db->ErrorMsg() ? $db->ErrorMsg() : $e->getMessage())); } }
public function install() { $pkg = parent::install(); Theme::add('sakan', $pkg); BlockType::installBlockTypeFromPackage('manual_nav', $pkg); }