public function import(\SimpleXMLElement $sx) { if (isset($sx->themes)) { foreach ($sx->themes->theme as $th) { $pkg = static::getPackageObject($th['package']); $pThemeHandle = (string) $th['handle']; $pt = Theme::getByHandle($pThemeHandle); if (!is_object($pt)) { $pt = Theme::add($pThemeHandle, $pkg); } if ($th['activated'] == '1') { $pt->applyToSite(); } } } }
/** * Returns an asset path relative to the theme directory. * If the second argument is given, it is used as the * theme handle for which the path is returned. If the * theme handle is not defined, the current theme is * used instead. * * @param \Less_Tree $urlTree * @param \Less_Tree|null $themeTree * * @return \Less_Tree */ public function themeAssetPath($urlTree, $themeTree = null) { $url = $urlTree->value; $theme = is_object($themeTree) ? $themeTree->value : null; if ($url[0] != '/') { $url = '/' . $url; } if (empty($theme)) { $theme = $this->getCurrentTheme(); } else { $to = Theme::getByHandle($theme); if (!is_object($to)) { throw new \Exception(t("Invalid theme-asset-url: %s, %s. A theme does not exist with handle: %s.", $url, $theme, $theme)); } $theme = $to; } // Default to theme URL $env = Environment::get(); $themeUrl = $env->getURL(DIRNAME_THEMES . '/' . $theme->getThemeHandle(), $theme->getPackageHandle()); $urlTree->value = $themeUrl . $url; return $urlTree; }
public function skipItem() { $theme = Theme::getByHandle($this->object->getHandle()); return is_object($theme); }
?> </title> <?php $canonical_link = $c->getCollectionLink(true); echo new \Concrete\Core\Html\Object\HeadLink($canonical_link, 'canonical'); ?> <meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1"> <script type="application/ld+json"> <?php if (is_object($c)) { /** @var \Concrete\Core\Localization\Service\Date $date */ $date = Core::make('helper/date'); /** @var \Concrete\Core\Utility\Service\Text $text */ $text = Core::make('helper/text'); /** @var \Concrete\Core\Page\Theme\Theme $theme */ $theme = \Concrete\Core\Page\Theme\Theme::getByHandle('amp'); $theme_url = Core::getApplicationURL() . $theme->getThemeURL(); $theme_path = DIR_BASE . $theme->getThemeURL(); // We can set a headline 3 ways: // 1. It comes through programmatically as $pageDescription. // 2. It comes from meta description // 3. It comes from getCollectionDescription() if (!isset($pageDescription) || !$pageDescription) { // we aren't getting it dynamically. $pageDescription = $c->getCollectionAttributeValue('meta_description'); if (!$pageDescription) { $pageDescription = $c->getCollectionDescription(); } } /** @var \Concrete\Core\User\UserInfo $author */ $author = Core::make('Concrete\\Core\\User\\UserInfoFactory')->getByID($c->getCollectionUserID());
/** * Returns an asset path relative to the theme directory. * The given arguments array needs to contain 1-2 values * in it as follows: * * 1. The first item in the array needs to be the relative * URL for which we want the full path for. * 2. The second item in the array can either be left out * or when defined, represent the theme handle. * * If the second argument is given, it is used as the * theme handle for which the path is returned. If the * theme handle is not defined, the current theme is * used instead. * * @param array $args * * @return string */ public function themeAssetPath(array $args) { list($url, $theme) = $args; $url = $this->extractStringFromArgument($url); $theme = $this->extractStringFromArgument($theme); if ($url[0] != '/') { $url = '/' . $url; } if (empty($theme)) { $theme = $this->getCurrentTheme(); } else { $to = Theme::getByHandle($theme); if (!is_object($to)) { throw new \Exception(t("Invalid theme-asset-url: %s, %s. A theme does not exist with handle: %s.", $url, $theme, $theme)); } $theme = $to; } // Default to theme URL $env = Environment::get(); $themeUrl = $env->getURL(DIRNAME_THEMES . '/' . $theme->getThemeHandle(), $theme->getPackageHandle()); return $themeUrl . $url; }
public function getFullPath($path, $dirName = null) { if ($path[0] == '@') { if (($pos = strpos($path, '/')) !== false) { $location = substr($path, 1, $pos); $subpath = substr($path, $pos + 1); $locationPath = ''; if ($location == 'core') { $locationPath = DIR_BASE_CORE; } elseif ($location == 'app') { $locationPath = DIR_APPLICATION; } elseif ($location == 'package') { if (($pos = strpos($subpath, '/')) !== false) { $pkgHandle = substr($subpath, 0, $pos); $subpath = substr($subpath, $pos + 1); $locationPath = DIR_PACKAGES . '/' . $pkgHandle; } else { throw new Exception(t("Invalid path: %s. Package not defined.", $path)); } } elseif ($location == 'theme') { if (($pos = strpos($subpath, '/')) !== false) { $themeHandle = substr($subpath, 0, $pos); $subpath = substr($subpath, $pos + 1); if (is_object($th = Theme::getByHandle($themeHandle))) { $env = Environment::get(); $locationPath = $env->getPath(DIRNAME_THEMES . '/' . $themeHandle, $th->getPackageHandle()); } else { throw new Exception(t("Invalid theme in path: %s. Theme '%s' does not exist.")); } } else { throw new Exception(t("Invalid path: %s. Theme not defined.", $path)); } } else { throw new Exception(t("Invalid path: %s. Unknown location: %s.", $path, $location)); } if (!empty($locationPath)) { return $locationPath . '/' . $dirName . '/' . $subpath; } } else { // This is an assetic alias, e.g. "@jquery". return $path; } } elseif ($path[0] == '/' || preg_match('#[a-z]:[/\\\\]#i', $path)) { return $path; } // Theme specific CSS (default) return $this->themeBasePath . '/' . $dirName . '/' . $path; }
public function configurePackage($pkg) { $theme = Theme::getByHandle('worldskills'); if (!is_object($theme)) { $theme = Theme::add('worldskills', $pkg); } // add skill ID attribute $attributeKey = CollectionAttributeKey::getByHandle('worldskills_skill_id'); if (!is_object($attributeKey)) { $type = AttributeType::getByHandle('text'); $args = array('akHandle' => 'worldskills_skill_id', 'akName' => t('Skill ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1); CollectionAttributeKey::add($type, $args, $pkg); } // add skill page type $pageType = \PageType::getByHandle('worldskills_skill'); if (!is_object($pageType)) { $template = \PageTemplate::getByHandle('full'); \PageType::add(array('handle' => 'worldskills_skill', 'name' => 'Skill', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all'))); } // add member ID attribute $attributeKey = CollectionAttributeKey::getByHandle('worldskills_member_id'); if (!is_object($attributeKey)) { $type = AttributeType::getByHandle('text'); $args = array('akHandle' => 'worldskills_member_id', 'akName' => t('Member ID'), 'akIsSearchable' => 1, 'akIsSearchableIndexed' => 1); CollectionAttributeKey::add($type, $args, $pkg); } // add member page type $pageType = \PageType::getByHandle('worldskills_member'); if (!is_object($pageType)) { $template = \PageTemplate::getByHandle('full'); \PageType::add(array('handle' => 'worldskills_member', 'name' => 'Member', 'defaultTemplate' => $template, 'allowedTemplates' => 'C', 'templates' => array($template), 'ptLaunchInComposer' => 0, 'ptIsFrequentlyAdded' => 0), $pkg)->setConfiguredPageTypePublishTargetObject(new PageTypePublishTargetAllConfiguration(PageTypePublishTargetAllType::getByHandle('all'))); } // add skill block $blockType = \BlockType::getByHandle('worldskills_skill'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_skill', $pkg); } // add skill list block $blockType = \BlockType::getByHandle('worldskills_skill_list'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_skill_list', $pkg); } // add people block $blockType = \BlockType::getByHandle('worldskills_people'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_people', $pkg); } // add member block $blockType = \BlockType::getByHandle('worldskills_member'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_member', $pkg); } // add member list block $blockType = \BlockType::getByHandle('worldskills_member_list'); if (!is_object($blockType)) { \BlockType::installBlockTypeFromPackage('worldskills_member_list', $pkg); } try { $authenticationType = AuthenticationType::getByHandle('worldskills'); } catch (\Exception $e) { $authenticationType = AuthenticationType::add('worldskills', 'WorldSkills Auth', 0, $pkg); $authenticationType->disable(); } $page = \SinglePage::add('/dashboard/system/basics/worldskills', $pkg); if (is_object($pag)) { $page->updateCollectionName('WorldSkills'); } \Config::save('worldskills.api_url', \Config::get('worldskills.api_url', 'https://api.worldskills.org')); \Config::save('worldskills.authorize_url', \Config::get('worldskills.authorize_url', 'https://auth.worldskills.org')); }