public function recordPageTypeComposerOutputBlock(\Concrete\Core\Block\Block $block)
 {
     $app = Application::getFacadeApplication();
     $db = $app->make('database')->connection();
     $setControl = $this->getPageTypeComposerFormLayoutSetControlObject();
     $db->executeQuery('insert into PageTypeComposerOutputBlocks (cID, arHandle, ptComposerFormLayoutSetControlID, cbDisplayOrder, bID) values (?, ?, ?, ?, ?)', [$block->getBlockCollectionID(), $block->getAreaHandle(), $setControl->getPageTypeComposerFormLayoutSetControlID(), $block->getBlockDisplayOrder(), $block->getBlockID()]);
 }
 public function setUp()
 {
     $this->app = clone \Concrete\Core\Support\Facade\Application::getFacadeApplication();
     $this->app['config'] = clone $this->app['config'];
     $this->request = Request::create('http://url.com/');
     $this->factory = new SessionFactory($this->app, $this->request);
 }
Example #3
0
 /**
  * @return string|null
  */
 public function getValue()
 {
     if ($this->value === null) {
         return null;
     } else {
         return Application::getFacadeApplication()->make('helper/number')->trim($this->value);
     }
 }
 protected function setUp()
 {
     $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
     $path_url_resolver = $app->make('Concrete\\Core\\Url\\Resolver\\PathUrlResolver');
     $routes = $app->make('Symfony\\Component\\Routing\\RouteCollection');
     $context = $app->make('Symfony\\Component\\Routing\\RequestContext');
     $generator = $app->make('Symfony\\Component\\Routing\\Generator\\UrlGenerator', array($routes, $context));
     $this->urlResolver = $app->make('Concrete\\Core\\Url\\Resolver\\RouteUrlResolver', array($path_url_resolver, $generator, $routes));
     $this->routeList = $routes;
 }
 public function renderSearchField()
 {
     $app = Application::getFacadeApplication();
     if (isset($this->data['versionToRetrieve']) && $this->data['versionToRetrieve']) {
         $versionToRetrieve = $this->data['versionToRetrieve'];
     } else {
         $versionToRetrieve = PageList::PAGE_VERSION_RECENT;
     }
     $form = $app->make('helper/form');
     $html = '<div class="radio"><label>' . $form->radio('versionToRetrieve', PageList::PAGE_VERSION_RECENT, $versionToRetrieve) . t('All') . '</label></div>';
     $html .= '<div class="radio"><label>' . $form->radio('versionToRetrieve', PageList::PAGE_VERSION_ACTIVE, $versionToRetrieve) . t('Approved') . '</label></div>';
     $html .= '<div class="radio"><label>' . $form->radio('versionToRetrieve', PageList::PAGE_VERSION_RECENT_UNAPPROVED, $versionToRetrieve) . t('Unapproved') . '</label></div>';
     return $html;
 }
 public function getAllBindings()
 {
     $bindings = [];
     $app = Application::getFacadeApplication();
     foreach ($app->getBindings() as $name => $binding) {
         try {
             $instance = $app->make($name);
             $className = get_class($instance);
             if (ltrim($name, '\\') != ltrim($className, '\\')) {
                 $bindings[$name] = $className;
             }
         } catch (\Exception $e) {
         }
     }
     return $bindings;
 }
 /** Executes the job.
  * @throws \Exception Throws an exception in case of errors.
  *
  * @return string Returns a string describing the job result in case of success.
  */
 public function run()
 {
     $pagination = (new PageList())->getPagination();
     $app = Application::getFacadeApplication();
     $tracker = $app->make('statistics/tracker');
     do {
         if ($results = $pagination->getCurrentPageResults()) {
             /** @var \Concrete\Core\Page\Page $page */
             foreach ($results as $page) {
                 try {
                     $tracker->track($page);
                 } catch (\Exception $e) {
                     dd($e->getMessage(), $e->getTraceAsString());
                 }
             }
         }
     } while ($pagination->hasNextPage() && $pagination->setCurrentPage($pagination->getNextPage()));
 }
 public function setUp()
 {
     $this->app = clone Application::getFacadeApplication();
     $this->app['config'] = clone $this->app['config'];
     $this->request = Request::create('http://url.com/');
     $this->validator = new SessionValidator($this->app, $this->app['config'], $this->request);
     $store = array();
     $mock = $this->getMockBuilder('Symfony\\Component\\HttpFoundation\\Session\\Session')->setMethods(array('has', 'get', 'set', 'invalidate', 'all'))->getMock();
     $mock->expects($this->any())->method('has')->willReturnCallback(function ($key) use(&$store) {
         return array_get($store, $key) !== null;
     });
     $mock->expects($this->any())->method('get')->willReturnCallback(function ($key, $default = null) use(&$store) {
         return array_get($store, $key, $default);
     });
     $mock->expects($this->any())->method('set')->willReturnCallback(function ($key, $value) use(&$store) {
         return $store[$key] = $value;
     });
     $mock->expects($this->any())->method('all')->willReturnCallback(function () use(&$store) {
         return $store;
     });
     $this->session = $mock;
 }
Example #9
0
 /**
  * Manage user session writing.
  *
  * @param bool $cache_interface
  */
 public function persist($cache_interface = true)
 {
     $this->refreshUserGroups();
     $app = Application::getFacadeApplication();
     /** @var \Symfony\Component\HttpFoundation\Session\Session $session */
     $session = $app['session'];
     $session->set('uID', $this->getUserID());
     $session->set('uName', $this->getUserName());
     $session->set('uBlockTypesSet', false);
     $session->set('uGroups', $this->getUserGroups());
     $session->set('uLastOnline', $this->getLastOnline());
     $session->set('uTimezone', $this->getUserTimezone());
     $session->set('uDefaultLanguage', $this->getUserDefaultLanguage());
     $session->set('uLastPasswordChange', $this->getLastPasswordChange());
     if ($cache_interface) {
         $app->make('helper/concrete/ui')->cacheInterfaceItems();
     }
 }
Example #10
0
 public static function getFileDateActivated($f)
 {
     $fv = $f->getVersion();
     $app = Application::getFacadeApplication();
     return $app->make('date')->formatDateTime($f->getDateAdded()->getTimestamp());
 }
Example #11
0
 /**
  * Export all the translations associates to every trees.
  *
  * @return Translations
  */
 public static function exportTranslations()
 {
     $translations = new Translations();
     $loc = Localization::getInstance();
     $loc->pushActiveContext('system');
     try {
         $app = Application::getFacadeApplication();
         $db = $app->make('database')->connection();
         $r = $db->executeQuery('select treeID from Trees order by treeID asc');
         while ($row = $r->fetch()) {
             try {
                 $tree = static::getByID($row['treeID']);
             } catch (Exception $x) {
                 $tree = null;
             }
             if (isset($tree)) {
                 /* @var $tree Tree */
                 $treeName = $tree->getTreeName();
                 if (is_string($treeName) && $treeName !== '') {
                     $translations->insert('TreeName', $treeName);
                 }
                 $rootNode = $tree->getRootTreeNodeObject();
                 /* @var $rootNode TreeNode */
                 if (isset($rootNode)) {
                     $rootNode->exportTranslations($translations);
                 }
             }
         }
     } catch (Exception $x) {
         $loc->popActiveContext();
         throw $x;
     }
     $loc->popActiveContext();
     return $translations;
 }
Example #12
0
 public function getSectionSiteInterfaceCompletionData(Section $section)
 {
     $app = Application::getFacadeApplication();
     $db = $app->make('database')->connection();
     $data = [];
     $data['messageCount'] = $db->fetchColumn('select count(mtID) from MultilingualTranslations where mtSectionID = ?', [$section->getCollectionID()]);
     $data['translatedCount'] = $db->fetchColumn('select count(mtID) from MultilingualTranslations where mtSectionID = ? and msgstr != ""', [$section->getCollectionID()]);
     $data['completionPercentage'] = 0;
     if ($data['messageCount'] > 0) {
         $data['completionPercentage'] = round($data['translatedCount'] / $data['messageCount'] * 100);
     }
     return $data;
 }
Example #13
0
 private function clearCanonicalUrl()
 {
     $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
     $app->make('Concrete\\Core\\Url\\Resolver\\CanonicalUrlResolver')->clearCached();
 }
Example #14
0
 public function getController()
 {
     $app = Application::getFacadeApplication();
     return $app->make(PackageService::class)->getClass($this->getPackageHandle());
 }
 protected function setUp()
 {
     $app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
     $this->urlResolver = $app->make('Concrete\\Core\\Url\\Resolver\\PageUrlResolver');
 }
Example #16
0
 /**
  * Can take an extension or a filename
  * Returns any registered information we have for the particular file type, based on its registration.
  *
  * @return FileType
  */
 public static function getType($ext)
 {
     $ftl = static::getInstance();
     if (strpos($ext, '.') !== false) {
         // filename
         $app = Application::getFacadeApplication();
         $h = $app->make('helper/file');
         $ext = $h->getExtension($ext);
     }
     $ext = strtolower($ext);
     if (isset($ftl->types[$ext])) {
         return $ftl->types[$ext];
     } else {
         $ft = new FileType();
         // generic
         return $ft;
     }
 }
Example #17
0
 /**
  * Returns an instance of the Concrete5 app object
  * @return \Concrete\Core\Support\Facade\Application
  */
 private function getApp()
 {
     if (is_null($this->app)) {
         $this->app = \Concrete\Core\Support\Facade\Application::getFacadeApplication();
     }
     return $this->app;
 }
Example #18
0
 public function delete()
 {
     Application::getFacadeApplication()->make('statistics/tracker')->forget($this);
     parent::delete();
 }
Example #19
0
 private function isPasswordReset()
 {
     $app = Application::getFacadeApplication();
     $db = $app['database']->connection();
     return $db->GetOne('select uIsPasswordReset from Users where uName = ?', array($this->post('uName')));
 }
 /**
  * An array of steps
  * Items: [ "option-name", "default-value", function($question, $input, $option) : $question ]
  * @return array
  */
 private function wizardSteps()
 {
     return [['db-server', '127.0.0.1'], 'db-database', 'db-username', ['db-password', function (Question $question, InputInterface $input) {
         return $question->setHidden(true);
     }], ['site', 'concrete5'], 'canonical-url', 'canonical-ssl-url', ['starting-point', 'elemental_blank', function (Question $question, InputInterface $input) {
         return new ChoiceQuestion($question->getQuestion(), ['elemental_full', 'elemental_blank'], $question->getDefault());
     }], 'admin-email', ['admin-password', function (Question $question, InputInterface $input) {
         $question->setNormalizer(function ($answer) {
             $error = new \ArrayObject();
             if (Application::getFacadeApplication()->make('validator/password')->isValid($answer, $error)) {
                 return $answer;
             }
             throw new \Exception(implode("\n", $error->getArrayCopy()));
         });
         return $question->setHidden(true);
     }], 'demo-username', 'demo-email', ['demo-password', function (Question $question, InputInterface $input) {
         return $question->setHidden(true);
     }], ['language', 'en_US'], ['site-locale', function (Question $question, InputInterface $input, InputOption $option) {
         $newDefault = $input->getOption('language');
         $newQuestion = $this->getQuestionString($option, $newDefault);
         return new Question($newQuestion, $newDefault);
     }], ['config', 'none']];
 }
Example #21
0
 public function flash($key, $value, $isHTML = false)
 {
     $session = Application::getFacadeApplication()->make('session');
     $session->getFlashBag()->add('page_message', array($key, $value, $isHTML));
 }
Example #22
0
 /**
  * Returns a thumbnail for this type of file.
  *
  * @param bool $fullImageTag Set to true to retrieve the full HTML image tag, false to just retrieve the image URL
  *
  * @return string
  */
 public function getThumbnail($fullImageTag = true)
 {
     $app = Application::getFacadeApplication();
     $config = $app->make('config');
     $type = ThumbnailType::getByHandle($config->get('concrete.icons.file_manager_listing.handle'));
     if (file_exists(DIR_AL_ICONS . '/' . $this->getExtension() . '.svg')) {
         $url = REL_DIR_AL_ICONS . '/' . $this->getExtension() . '.svg';
     } else {
         $url = AL_ICON_DEFAULT;
     }
     if ($fullImageTag == true) {
         return sprintf('<img src="%s" width="%s" height="%s" class="img-responsive ccm-generic-thumbnail">', $url, $type->getWidth(), $type->getHeight());
     } else {
         return $url;
     }
 }
 public function delete()
 {
     $app = Application::getFacadeApplication();
     $db = $app->make('database')->connection();
     $db->executeQuery('delete from PageTypeComposerFormLayoutSetControls where ptComposerFormLayoutSetControlID = ?', [$this->ptComposerFormLayoutSetControlID]);
     $db->executeQuery('delete from PageTypeComposerOutputControls where ptComposerFormLayoutSetControlID = ?', [$this->ptComposerFormLayoutSetControlID]);
     $set = $this->getPageTypeComposerFormLayoutSetObject();
     $set->rescanFormLayoutSetControlDisplayOrder();
 }