Ejemplo n.º 1
0
 /**
  * @param Section $section
  * @return StackCategory
  */
 public static function createFromMultilingualSection(Section $section)
 {
     $parent = \Page::getByPath(STACKS_PAGE_PATH);
     $data = array();
     $data['name'] = $section->getLocale();
     $data['cHandle'] = $section->getLocale();
     $type = Type::getByHandle(STACK_CATEGORY_PAGE_TYPE);
     $page = $parent->add($type, $data);
     $sc = new StackCategory($page);
     return $sc;
 }
Ejemplo n.º 2
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     if (\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale')) {
         return;
     }
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     // don't translate dashboard pages
     $dh = \Core::make('helper/concrete/dashboard');
     if ($dh->inDashboard($c)) {
         return;
     }
     $ms = Section::getBySectionOfSite($c);
     if (!is_object($ms)) {
         $ms = static::getPreferredSection();
     }
     if (!$ms) {
         return;
     }
     $locale = $ms->getLocale();
     if (strlen($locale)) {
         \Localization::changeLocale($locale);
     }
 }
 public function getMembers()
 {
     // get locale
     $locale = \Localization::activeLocale();
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $al = Section::getBySectionOfSite($c);
         if (is_object($al)) {
             $locale = $al->getLocale();
         }
     }
     // fix for sorting
     if ($locale == 'en_US') {
         $locale = 'en';
     }
     $params = array('limit' => 100, 'member_of' => $this->parentId, 'sort' => '1058', 'l' => $locale);
     // build URL with params
     $uh = \Core::make('helper/url');
     $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/org/members';
     $url = $uh->buildQuery($url, $params);
     // fetch JSON
     $data = \Core::make("helper/file")->getContents($url);
     $data = json_decode($data, true);
     return $data;
 }
Ejemplo n.º 4
0
 public function view()
 {
     $this->requireAsset('javascript', 'jquery');
     $ml = Section::getList();
     $c = \Page::getCurrentPage();
     $al = Section::getBySectionOfSite($c);
     $languages = [];
     $locale = null;
     if ($al !== null) {
         $locale = $al->getLanguage();
     }
     if (!$locale) {
         $locale = \Localization::activeLocale();
         $al = Section::getByLocale($locale);
     }
     foreach ($ml as $m) {
         $languages[$m->getCollectionID()] = $m->getLanguageText($m->getLocale());
     }
     $this->set('languages', $languages);
     $this->set('languageSections', $ml);
     $this->set('activeLanguage', $al ? $al->getCollectionID() : null);
     $dl = $this->app->make('multilingual/detector');
     $this->set('defaultLocale', $dl->getPreferredSection());
     $this->set('locale', $locale);
     $this->set('cID', $c->getCollectionID());
 }
Ejemplo n.º 5
0
 public function getDashboardSitemapIconSRC($page)
 {
     $ids = Section::getIDList();
     if (in_array($page->getCollectionID(), $ids)) {
         return self::getSectionFlagIcon($page, true);
     }
 }
Ejemplo n.º 6
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     if (!$c) {
         $c = Page::getCurrentPage();
     }
     $app = Facade::getFacadeApplication();
     // don't translate dashboard pages
     $dh = $app->make('helper/concrete/dashboard');
     if ($dh->inDashboard($c)) {
         return;
     }
     $ms = Section::getBySectionOfSite($c);
     if (!is_object($ms)) {
         $ms = static::getPreferredSection();
     }
     if (!$ms) {
         return;
     }
     $locale = $ms->getLocale();
     if ($locale) {
         $app->make('session')->set('multilingual_default_locale', $locale);
         $loc = Localization::getInstance();
         $loc->setContextLocale('site', $locale);
     }
 }
 public function __construct(Page $page, Dashboard $dashboard, Flag $flagService)
 {
     $this->page = $page;
     $this->dashboard = $dashboard;
     $this->flagService = $flagService;
     $this->multilingualSection = \Concrete\Core\Multilingual\Page\Section\Section::getBySectionOfSite($page);
 }
Ejemplo n.º 8
0
 public static function setupSiteInterfaceLocalization(Page $c = null)
 {
     $loc = \Localization::getInstance();
     if (!(\User::isLoggedIn() && Config::get('concrete.multilingual.keep_users_locale'))) {
         if (!$c) {
             $c = Page::getCurrentPage();
         }
         // don't translate dashboard pages
         $dh = \Core::make('helper/concrete/dashboard');
         if ($dh->inDashboard($c)) {
             return;
         }
         $locale = null;
         $ms = Section::getBySectionOfSite($c);
         if ($ms) {
             $locale = $ms->getLocale();
         }
         if (!$locale) {
             if (Config::get('concrete.multilingual.use_previous_locale') && Session::has('previous_locale')) {
                 $locale = Session::get('previous_locale');
             }
             if (!$locale) {
                 $ms = static::getPreferredSection();
                 if ($ms) {
                     $locale = $ms->getLocale();
                 }
             }
         }
         if ($locale) {
             $loc->setLocale($locale);
         }
     }
     Session::set('previous_locale', $loc->getLocale());
 }
Ejemplo n.º 9
0
 public function rescan_locale()
 {
     if ($this->token->validate('rescan_locale')) {
         $u = new \User();
         if ($u->isSuperUser()) {
             \Core::make('cache/request')->disable();
             $section = Section::getByID($_REQUEST['locale']);
             $target = new MultilingualProcessorTarget($section);
             $processor = new Processor($target);
             if ($_POST['process']) {
                 foreach ($processor->receive() as $task) {
                     $processor->execute($task);
                 }
                 $obj = new \stdClass();
                 $obj->totalItems = $processor->getTotalTasks();
                 echo json_encode($obj);
                 exit;
             } else {
                 $processor->process();
             }
             $totalItems = $processor->getTotalTasks();
             \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
             exit;
         }
     }
 }
Ejemplo n.º 10
0
 public function rescan_locale()
 {
     if ($this->token->validate('rescan_locale')) {
         $u = new \User();
         if ($u->isSuperUser()) {
             \Core::make('cache/request')->disable();
             $section = Section::getByID($_REQUEST['locale']);
             $target = new MultilingualProcessorTarget($section);
             $processor = new Processor($target);
             if ($_POST['process']) {
                 foreach ($processor->receive() as $task) {
                     $processor->execute($task);
                 }
                 $obj = new \stdClass();
                 $obj->totalItems = $processor->getTotalTasks();
                 print json_encode($obj);
                 exit;
             } else {
                 $processor->process();
             }
             $totalItems = $processor->getTotalTasks();
             \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d task", "%d tasks", $totalItems)));
             /*
             $q = Queue::get('rescan_multilingual_section');
             if ($_POST['process']) {
                 $obj = new \stdClass;
                 $messages = $q->receive(\Config::get('concrete.limits.copy_pages'));
                 foreach($messages as $key => $p) {
                     // delete the page here
                     $page = unserialize($p->body);
                     $oc = \Page::getByID($page['cID']);
             
             
                     $q->deleteMessage($p);
                 }
             
                 $obj->totalItems = $q->count();
                 print json_encode($obj);
                 if ($q->count() == 0) {
                     $q->deleteQueue('rescan_multilingual_section');
                 }
                 exit;
             
             } else if ($q->count() == 0) {
                 $oc = Section::getByID($_REQUEST['locale']);
                 if (is_object($oc) && !$oc->isError()) {
                     $oc->queueForDeletionRequest($q, false);
                 }
             }
             $totalItems = $q->count();
             \View::element('progress_bar', array('totalItems' => $totalItems, 'totalItemsSummary' => t2("%d page", "%d pages", $totalItems)));
             */
             exit;
         }
     }
 }
Ejemplo n.º 11
0
 public static function getNewsPage()
 {
     $currentSection = Section::getCurrentSection();
     if ($currentSection) {
         $localeID = $currentSection->getCollectionID();
     } else {
         return false;
     }
     return self::getChildPage($localeID, "news");
 }
Ejemplo n.º 12
0
 protected function canAccess()
 {
     $app = \Core::make("app");
     $dashboard = $app->make('helper/concrete/dashboard');
     if ($app->make('multilingual/detector')->isEnabled() && is_object(Section::getCurrentSection()) && !$dashboard->inDashboard($this->page) && $this->permissions->canEditPageMultilingualSettings()) {
         return true;
     }
     if (!$dashboard->inDashboard($this->page) && count($this->page->getPageRelations()) > 0) {
         return true;
     }
     return false;
 }
Ejemplo n.º 13
0
 public static function getDashboardSitemapIconSRC($page)
 {
     if ($page->getPageTypeHandle() == STACK_CATEGORY_PAGE_TYPE) {
         $section = Section::getByLocale($page->getCollectionName());
         if (is_object($section)) {
             return self::getSectionFlagIcon($section, true);
         }
     }
     $ids = Section::getIDList();
     if (in_array($page->getCollectionID(), $ids)) {
         return self::getSectionFlagIcon($page, true);
     }
 }
Ejemplo n.º 14
0
 public function finalizeQuery(QueryBuilder $query)
 {
     $query = parent::finalizeQuery($query);
     $mslist = Section::getList();
     $relation = Database::get()->createQueryBuilder();
     $relation->select('mpRelationID')->from('MultilingualPageRelations', 'mppr')->where('cID = p.cID')->setMaxResults(1);
     $query->addSelect('(' . $relation . ') as mpr');
     foreach ($mslist as $ms) {
         $section = Database::get()->createQueryBuilder();
         $section->select('count(mpRelationID)')->from('MultilingualPageRelations', 'mppr')->where('mpRelationID = mpr')->andWhere($section->expr()->comparison('mpLocale', '=', $query->createNamedParameter($ms->getLocale())));
         $query->addSelect('(' . $section . ') as relationCount' . $ms->getCollectionID());
     }
     return $query;
 }
Ejemplo n.º 15
0
 public function finalizeQuery(QueryBuilder $query)
 {
     $db = Database::connection();
     $query = parent::finalizeQuery($query);
     $mainRelation = $db->createQueryBuilder();
     $mainRelation->select('mpr0.cID')->addSelect('MIN(mpr0.mpRelationID) as mpr')->from('MultilingualPageRelations', 'mpr0')->groupBy('mpr0.cID');
     $query->addSelect('mppr.mpr')->leftJoin('p', '(' . $mainRelation . ')', 'mppr', 'p.cID = mppr.cID');
     $mslist = Section::getList();
     foreach ($mslist as $ms) {
         $cID = (int) $ms->getCollectionID();
         $cLocale = (string) $ms->getLocale();
         $query->addSelect("count(mppr{$cID}.mpRelationID) as relationCount{$cID}")->leftJoin('mppr', 'MultilingualPageRelations', "mppr{$cID}", "mppr.mpr = mppr{$cID}.mpRelationID AND " . $db->quote($cLocale) . " = mppr{$cID}.mpLocale");
     }
     $query->addGroupBy(['p.cID', 'mppr.mpr']);
     return $query;
 }
Ejemplo n.º 16
0
 public function create_new()
 {
     $pr = new PageEditResponse();
     $ms = Section::getByID($this->request->request->get('section'));
     // we get the related parent id
     $cParentID = $this->page->getCollectionParentID();
     $cParent = \Page::getByID($cParentID);
     $cParentRelatedID = $ms->getTranslatedPageID($cParent);
     if ($cParentRelatedID > 0) {
         // we copy the page underneath it and store it
         $newParent = \Page::getByID($cParentRelatedID);
         $ct = \PageType::getByID($this->page->getPageTypeID());
         $cp = new \Permissions($newParent);
         if ($cp->canAddSubCollection($ct) && $this->page->canMoveCopyTo($newParent)) {
             $newPage = $this->page->duplicate($newParent);
             if (is_object($newPage)) {
                 // grab the approved version and unapprove it
                 $v = Version::get($newPage, 'ACTIVE');
                 if (is_object($v)) {
                     $v->deny();
                     $pkr = new ApprovePageRequest();
                     $pkr->setRequestedPage($newPage);
                     $u = new \User();
                     $pkr->setRequestedVersionID($v->getVersionID());
                     $pkr->setRequesterUserID($u->getUserID());
                     $response = $pkr->trigger();
                     if (!$response instanceof Response) {
                         // we are deferred
                         $pr->setMessage(t('<strong>Request Saved.</strong> You must complete the workflow before this change is active.'));
                     } else {
                         $ih = Core::make('multilingual/interface/flag');
                         $icon = $ih->getSectionFlagIcon($ms);
                         $pr->setAdditionalDataAttribute('name', $newPage->getCollectionName());
                         $pr->setAdditionalDataAttribute('link', $newPage->getCollectionLink());
                         $pr->setAdditionalDataAttribute('icon', $icon);
                         $pr->setMessage(t('Page created.'));
                     }
                 }
             }
         } else {
             throw new \Exception(t('You do not have permission to add this page to this section of the tree.'));
         }
     }
     $pr->outputJSON();
 }
Ejemplo n.º 17
0
 public function view()
 {
     $this->requireAsset('core/sitemap');
     $mlist = Section::getList();
     $ml = array();
     $currentSection = Section::getCurrentSection();
     foreach ($mlist as $m) {
         if ($m->getCollectionID() != $currentSection->getCollectionID()) {
             $ml[] = $m;
         }
     }
     $this->set('list', $ml);
     $this->set('currentSection', $currentSection);
     $this->set('ih', Core::make('multilingual/interface/flag'));
     $multilingualController = Core::make('\\Concrete\\Controller\\Backend\\Page\\Multilingual');
     $multilingualController->setPageObject($this->page);
     $this->set('multilingualController', $multilingualController);
 }
 public function getMember()
 {
     // get locale
     $locale = \Localization::activeLocale();
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $al = Section::getBySectionOfSite($c);
         if (is_object($al)) {
             $locale = $al->getLocale();
         }
     }
     // build URL with params
     $uh = \Core::make('helper/url');
     $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/org/members/' . $this->memberId;
     $url = $uh->buildQuery($url, array('l' => $locale));
     // fetch JSON
     $data = \Core::make("helper/file")->getContents($url);
     $data = json_decode($data, true);
     return $data;
 }
Ejemplo n.º 19
0
 protected function getSelectedLanguage()
 {
     $defaultLanguage = false;
     $defaultLocale = Config::get('concrete.multilingual.default_locale');
     if (!$defaultLocale) {
         throw new \Exception(t('You must specify a default language tree in your multilingual settings.'));
     }
     foreach ($this->multilingualSections as $section) {
         if ($section->getLocale() == $defaultLocale) {
             $defaultLanguage = $section;
         }
     }
     $session = Core::make('session');
     if ($session->has('stacksDefaultLanguageID')) {
         $section = Section::getByID($session->get('stacksDefaultLanguageID'));
         if (is_object($section)) {
             $defaultLanguage = $section;
         }
     }
     return $defaultLanguage;
 }
Ejemplo n.º 20
0
 protected function load()
 {
     parent::load();
     $this->set('stIDNeutral', null);
     $stack = Stack::getByID($this->stID);
     if ($stack && $stack->isNeutralStack()) {
         $detector = isset($this->app) ? $this->app->make('multilingual/detector') : \Core::make('multilingual/detector');
         /* @var \Concrete\Core\Multilingual\Service\Detector $detector */
         if ($detector->isEnabled()) {
             $section = Section::getCurrentSection();
             if ($section) {
                 $localized = $stack->getLocalizedStack($section);
                 if ($localized) {
                     $this->stIDNeutral = $this->stID;
                     $this->stID = $localized->getCollectionID();
                     $this->set('stIDNeutral', $this->stIDNeutral);
                     $this->set('stID', $this->stID);
                 }
             }
         }
     }
 }
 public function getSkills($sort = 'name_asc')
 {
     // get locale
     $locale = \Localization::activeLocale();
     $c = $this->getCollectionObject();
     if (is_object($c)) {
         $al = Section::getBySectionOfSite($c);
         if (is_object($al)) {
             $locale = $al->getLocale();
         }
     }
     // fix for sorting
     if ($locale == 'en_US') {
         $locale = 'en';
     }
     // defaults
     $params = array('limit' => 100, 'sort' => $sort, 'l' => $locale);
     // build URL with params
     $url = \Config::get('worldskills.api_url', 'https://api.worldskills.org') . '/events/' . $this->eventId . '/skills';
     $url .= '?';
     $url .= http_build_query($params);
     // block settings
     if ($this->sectorId) {
         $url .= '&';
         $url .= http_build_query(array('sector' => $this->sectorId));
     }
     if ($this->types) {
         $skillTypes = explode(',', $this->types);
         foreach ($skillTypes as $skillType) {
             $url .= '&';
             $url .= http_build_query(array('type' => $skillType));
         }
     }
     // fetch JSON
     $data = \Core::make("helper/file")->getContents($url);
     $data = json_decode($data, true);
     return $data;
 }
Ejemplo n.º 22
0
 /**
  * Get the site name localized for a specific page.
  *
  * @param \Concrete\Core\Page\Page $page
  *
  * @return string
  */
 public function getSiteNameForPage(\Concrete\Core\Page\Page $page)
 {
     static $multilingual;
     static $defaultLocale;
     if (!isset($multilingual)) {
         $multilingual = $this->app->make('multilingual/detector')->isEnabled();
     }
     if ($multilingual) {
         if (!isset($defaultLocale)) {
             $defaultLocale = $this->app->make('config')->get('concrete.locale') ?: 'en_US';
         }
         $section = Section::getBySectionOfSite($page);
         if ($section) {
             $locale = $section->getLocale();
         } else {
             $locale = $defaultLocale;
         }
         $siteName = $this->getSiteNameForLocale($locale);
     } else {
         $siteName = $this->app->make('config')->get('concrete.site');
     }
     return $siteName;
 }
Ejemplo n.º 23
0
 public static function rescanMultilingualStacks()
 {
     $sl = new static();
     $stacks = $sl->get();
     foreach ($stacks as $stack) {
         $section = $stack->getMultilingualSection();
         if (!$section) {
             $section = false;
             $parent = \Page::getByID($stack->getCollectionParentID());
             if ($parent->getCollectionPath() == STACKS_PAGE_PATH) {
                 // this is the default
                 $section = Section::getDefaultSection();
             } else {
                 if ($parent->getPageTypeHandle() == STACK_CATEGORY_PAGE_TYPE) {
                     $locale = $parent->getCollectionHandle();
                     $section = Section::getByLocale($locale);
                 }
             }
             if ($section) {
                 $stack->updateMultilingualSection($section);
             }
         }
     }
 }
Ejemplo n.º 24
0
    if (count($sections) > 0) {
        $width = 100 / count($sections);
    } else {
        $width = '100';
    }
    ?>

    <div class="table-responsive">
        <table class="ccm-search-results-table">
            <thead>
            <tr>
                <th style="width: <?php 
    echo $width;
    ?>
%"><span><?php 
    $sourceMS = \Concrete\Core\Multilingual\Page\Section\Section::getByID($sectionID);
    print t('%s (%s)', $sourceMS->getLanguageText(), $sourceMS->getLocale());
    ?>
                </span></th>
                <?php 
    foreach ($targetList as $sc) {
        ?>
                    <?php 
        if ($section->getCollectionID() != $sc->getCollectionID()) {
            ?>
                        <th style="width:<?php 
            echo $width;
            ?>
%"><span><?php 
            print $fh->getSectionFlagIcon($sc);
            print '&nbsp;';
Ejemplo n.º 25
0
 public function view()
 {
     $this->requireAsset('core/sitemap');
     $list = MultilingualSection::getList();
     $sections = array();
     usort($list, function ($item) {
         if ($item->getLocale() == \Config::get('concrete.multilingual.default_locale')) {
             return -1;
         } else {
             return 1;
         }
     });
     foreach ($list as $pc) {
         $sections[$pc->getCollectionID()] = $pc->getLanguageText() . " (" . $pc->getLocale() . ")";
     }
     $this->set('sections', $sections);
     $this->set('sectionList', $list);
     if (!isset($_REQUEST['sectionID']) && count($sections) > 0) {
         foreach ($sections as $key => $value) {
             $sectionID = $key;
             break;
         }
     } else {
         $sectionID = $_REQUEST['sectionID'];
     }
     if (!isset($_REQUEST['targets']) && count($sections) > 1) {
         $i = 0;
         foreach ($sections as $key => $value) {
             if ($key != $sectionID) {
                 $targets[$key] = $key;
                 break;
             }
             $i++;
         }
     } else {
         $targets = $_REQUEST['targets'];
     }
     if (!isset($targets) || !is_array($targets)) {
         $targets = array();
     }
     $targetList = array();
     foreach ($targets as $key => $value) {
         $targetList[] = MultilingualSection::getByID($key);
     }
     $this->set('targets', $targets);
     $this->set('targetList', $targetList);
     $this->set('sectionID', $sectionID);
     $this->set('fh', \Core::make('multilingual/interface/flag'));
     if (isset($sectionID) && $sectionID > 0) {
         $pl = new MultilingualPageList();
         $pc = \Page::getByID($sectionID);
         $path = $pc->getCollectionPath();
         if (strlen($path) > 1) {
             $pl->filterByPath($path);
         }
         if ($_REQUEST['keywords']) {
             $pl->filterByName($_REQUEST['keywords']);
         }
         $pl->setItemsPerPage(25);
         if (!$_REQUEST['showAllPages']) {
             $pl->filterByMissingTargets($targetList);
         }
         $pagination = $pl->getPagination();
         $this->set('pagination', $pagination);
         $this->set('pages', $pagination->getCurrentPageResults());
         $this->set('section', MultilingualSection::getByID($sectionID));
         $this->set('pl', $pl);
     }
 }
Ejemplo n.º 26
0
 /**
  * Adds a new page of a certain type, using a passed associate array to setup value. $data may contain any or all of the following:
  * "uID": User ID of the page's owner
  * "pkgID": Package ID the page belongs to
  * "cName": The name of the page
  * "cHandle": The handle of the page as used in the path
  * "cDatePublic": The date assigned to the page.
  *
  * @param \Concrete\Core\Page\Type\Type $pt
  * @param array $data
  *
  * @return page
  **/
 public function add($pt, $data, $template = false)
 {
     $data += array('cHandle' => null);
     $db = Database::get();
     $txt = Core::make('helper/text');
     // the passed collection is the parent collection
     $cParentID = $this->getCollectionID();
     $u = new User();
     if (isset($data['uID'])) {
         $uID = $data['uID'];
     } else {
         $uID = $u->getUserID();
         $data['uID'] = $uID;
     }
     if (isset($data['pkgID'])) {
         $pkgID = $data['pkgID'];
     } else {
         $pkgID = 0;
     }
     if (isset($data['cName'])) {
         $data['name'] = $data['cName'];
     }
     if (!$data['cHandle']) {
         // make the handle out of the title
         $handle = $txt->urlify($data['name']);
     } else {
         $handle = $txt->slugSafeString($data['cHandle']);
         // we take it as it comes.
     }
     $handle = str_replace('-', Config::get('concrete.seo.page_path_separator'), $handle);
     $data['handle'] = $handle;
     $ptID = 0;
     $masterCIDBlocks = null;
     $masterCID = null;
     if ($pt instanceof \Concrete\Core\Page\Type\Type) {
         if ($pt->getPageTypeHandle() == STACKS_PAGE_TYPE) {
             $data['cvIsNew'] = 0;
         }
         if ($pt->getPackageID() > 0) {
             $pkgID = $pt->getPackageID();
         }
         // if we have a page type and we don't have a template,
         // then we use the page type's default template
         if ($pt->getPageTypeDefaultPageTemplateID() > 0 && !$template) {
             $template = $pt->getPageTypeDefaultPageTemplateObject();
         }
         $ptID = $pt->getPageTypeID();
         if ($template) {
             $mc1 = $pt->getPageTypePageTemplateDefaultPageObject($template);
             $mc2 = $pt->getPageTypePageTemplateDefaultPageObject();
             $masterCIDBlocks = $mc1->getCollectionID();
             $masterCID = $mc2->getCollectionID();
         }
     }
     if ($template instanceof PageTemplate) {
         $data['pTemplateID'] = $template->getPageTemplateID();
     }
     $cobj = parent::addCollection($data);
     $cID = $cobj->getCollectionID();
     //$this->rescanChildrenDisplayOrder();
     $cDisplayOrder = $this->getNextSubPageDisplayOrder();
     $cInheritPermissionsFromCID = $this->overrideTemplatePermissions() ? $this->getPermissionsCollectionID() : $masterCID;
     $cInheritPermissionsFrom = $this->overrideTemplatePermissions() ? 'PARENT' : 'TEMPLATE';
     $v = array($cID, $ptID, $cParentID, $uID, $cInheritPermissionsFrom, $this->overrideTemplatePermissions(), $cInheritPermissionsFromCID, $cDisplayOrder, $pkgID);
     $q = 'insert into Pages (cID, ptID, cParentID, uID, cInheritPermissionsFrom, cOverrideTemplatePermissions, cInheritPermissionsFromCID, cDisplayOrder, pkgID) values (?, ?, ?, ?, ?, ?, ?, ?, ?)';
     $r = $db->prepare($q);
     $res = $db->execute($r, $v);
     $newCID = $cID;
     if ($res) {
         // Collection added with no problem -- update cChildren on parrent
         PageStatistics::incrementParents($newCID);
         if ($r) {
             // now that we know the insert operation was a success, we need to see if the collection type we're adding has a master collection associated with it
             if ($masterCIDBlocks) {
                 $this->_associateMasterCollectionBlocks($newCID, $masterCIDBlocks);
             }
             if ($masterCID) {
                 $this->_associateMasterCollectionAttributes($newCID, $masterCID);
             }
         }
         $pc = Page::getByID($newCID, 'RECENT');
         // if we are in the drafts area of the site, then we don't check multilingual status. Otherwise
         // we do
         if ($this->getCollectionPath() != Config::get('concrete.paths.drafts')) {
             Section::registerPage($pc);
         }
         if ($template) {
             $pc->acquireAreaStylesFromDefaults($template);
         }
         // run any internal event we have for page addition
         $pe = new Event($pc);
         Events::dispatch('on_page_add', $pe);
         $pc->rescanCollectionPath();
     }
     return $pc;
 }
Ejemplo n.º 27
0
<?php 
if (count($pages)) {
    ?>

    <fieldset>
        <legend><?php 
    echo t('Copy Locale Tree');
    ?>
</legend>
    <?php 
    $u = new User();
    $copyLocales = array();
    $includesHome = false;
    foreach ($pages as $pc) {
        $pcl = MultilingualSection::getByID($pc->getCollectionID());
        if ($pc->getCollectionID() == HOME_CID) {
            $includesHome = true;
        }
        $copyLocales[$pc->getCollectionID()] = tc('PageWithLocale', '%1$s (%2$s, %3$s)', $pc->getCollectionName(), $pcl->getLanguageText(), $pcl->getLocale());
    }
    if ($u->isSuperUser() && !$includesHome) {
        ?>
    <form method="post" id="ccm-internationalization-copy-tree" action="#">
        <?php 
        if (count($pages) > 1) {
            $copyLocaleSelect1 = $form->select('copyTreeFrom', $copyLocales);
            $copyLocaleSelect2 = $form->select('copyTreeTo', $copyLocales);
            ?>
            <p><?php 
            echo t('Copy all pages from a locale to another section. This will only copy pages that have not been associated. It will not replace or remove any pages from the destination section.');
Ejemplo n.º 28
0
 // now we check to see if the parent ID of the current record has already been duplicated somewhere.
 $newCID = $db->GetOne('select cID from QueuePageDuplicationRelations where originalCID = ? and queue_name = ?', array($page['cParentID'], 'copy_page'));
 if ($newCID > 0) {
     $dc = Page::getByID($newCID);
 } else {
     $dc = Page::getByID($page['destination']);
 }
 if ($_POST['multilingual']) {
     // Find multilingual section of the destination
     if (Section::isMultilingualSection($dc)) {
         $ms = Section::getByID($dc->getCollectionID());
     } else {
         $ms = Section::getBySectionOfSite($dc);
     }
     // Is page already copied?
     $existingCID = Section::getRelatedCollectionIDForLocale($page['cID'], $ms->getLocale());
     if ($existingCID) {
         $nc = Page::getById($existingCID);
         if ($dc->getCollectionID() != $nc->getCollectionParentID()) {
             $nc->move($dc);
         }
     } else {
         $nc = $oc->duplicate($dc);
     }
 } else {
     $nc = $oc->duplicate($dc);
 }
 $ocID = $oc->getCollectionID();
 $ncID = $nc->getCollectionID();
 if ($oc->getCollectionPointerOriginalID() > 0) {
     $ocID = $oc->getCollectionPointerOriginalID();
                                            title="<?php 
    echo t('Add Pages and Navigate Your Site');
    ?>
"
                                            data-launch-panel="sitemap">
                        <i class="fa fa-files-o"></i>
                <span class="ccm-toolbar-accessibility-title ccm-toolbar-accessibility-title-add-page">
                    <?php 
    echo tc('toolbar', 'Pages');
    ?>
                </span>
            </a>
        </li>
        <?php 
    if ($cp->canEditPageMultilingualSettings() && \Core::make('multilingual/detector')->isEnabled()) {
        $section = \Concrete\Core\Multilingual\Page\Section\Section::getCurrentSection();
        $ch = Core::make('multilingual/interface/flag');
        if (is_object($section)) {
            ?>
                <li class="pull-right hidden-xs">
                <a href="#" data-panel-url="<?php 
            echo URL::to('/ccm/system/panels/multilingual');
            ?>
"
                   title="<?php 
            echo t('Navigate this page in other languages');
            ?>
"
                   data-launch-panel="multilingual">
                    <?php 
            print $ch->getFlagIcon($section->getIcon());
Ejemplo n.º 30
0
 public function updateMultilingualSection(Section $section)
 {
     $db = Database::connection();
     $db->Execute('update Stacks set stMultilingualSection = ? where cID = ?', array($section->getCollectionID(), $this->getCollectionID()));
 }