public function run() { $this->x = new SimpleXMLElement("<concrete5-cif></concrete5-cif>"); $this->x->addAttribute('version', '1.0'); // First, attribute categories AttributeKeyCategory::exportList($this->x); // attribute types AttributeType::exportList($this->x); // then block types BlockTypeList::exportList($this->x); // now attribute keys (including user) AttributeKey::exportList($this->x); // now attribute keys (including user) AttributeSet::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 Loader::model('job'); 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 page types CollectionType::exportList($this->x); // now stacks/global areas Loader::model('stack/list'); StackList::export($this->x); // now content pages $pages = $this->x->addChild("pages"); $db = Loader::db(); $r = $db->Execute('select Pages.cID from Pages left join ComposerDrafts on Pages.cID = ComposerDrafts.cID where ComposerDrafts.cID is null and cIsTemplate = 0 and cFilename is null or cFilename = "" order by cID asc'); while ($row = $r->FetchRow()) { $pc = Page::getByID($row['cID'], 'RECENT'); $pc->export($pages); } Loader::model("system/captcha/library"); SystemCaptchaLibrary::exportList($this->x); Config::exportList($this->x); }
static function changeLocale($locale) { // change core language to translate e.g. core blocks/themes if (strlen($locale)) { Localization::changeLocale($locale); // site translations $loc = Localization::getInstance(); $loc->addSiteInterfaceLanguage($locale); // add package translations $pl = PackageList::get(); $installed = $pl->getPackages(); foreach ($installed as $pkg) { if ($pkg instanceof Package) { $pkg->setupPackageLocalization($locale); } } } }
public function exportAll() { $this->x = $this->getXMLRoot(); // First, attribute categories AttributeKeyCategory::exportList($this->x); // attribute types AttributeType::exportList($this->x); // then block types BlockTypeList::exportList($this->x); // now attribute keys (including user) AttributeKey::exportList($this->x); // now attribute keys (including user) AttributeSet::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 Loader::model('job'); 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 page types CollectionType::exportList($this->x); // now stacks/global areas Loader::model('stack/list'); StackList::export($this->x); $this->exportPages($this->x); Loader::model("system/captcha/library"); SystemCaptchaLibrary::exportList($this->x); Config::exportList($this->x); }
protected function getIncludeFile($view) { $atHandle = $this->attributeType->getAttributeTypeHandle(); if (file_exists(DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php')) { $file = DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php'; } if (!isset($file) && $this->attributeType->getPackageID() > 0) { $pkgHandle = PackageList::getHandle($this->attributeType->getPackageID()); $dirp = is_dir(DIR_PACKAGES . '/' . $pkgHandle) ? DIR_PACKAGES . '/' . $pkgHandle : DIR_PACKAGES_CORE . '/' . $pkgHandle; if (file_exists($dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php')) { $file = $dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php'; } } if (!isset($file)) { if (file_exists(DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php')) { $file = DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php'; } } return $file; }
<?php defined('C5_EXECUTE') or die("Access Denied."); $pla = PackageList::get(); $pl = $pla->getPackages(); foreach ($pl as $p) { if ($p->isPackageInstalled()) { $pkg = Loader::package($p->getPackageHandle()); if (is_object($pkg)) { if (method_exists($pkg, 'on_start')) { $pkg->on_start(); } } } }
function get_packages($pname = 'all', $local = true) { $pkgs = new PackageList(); $pkgs->load(); $lists = array(); foreach ($pkgs->pkgs as $dir => $pkg) { if (empty($dir)) { $pname = $pkgs->getBaseName(); foreach ($pkg as $info) { if ($info['pname'] == $pname) { $lists[$dir] = $info; break; } } } else { if (count($pkg)) { $lists[$dir] = $pkg[0]; } } } if (!$local) { return $lists; } // add inactive modules $base = XOOPS_ROOT_PATH . "/modules"; $dh = opendir($base); $mlist = array(); while ($dir = readdir($dh)) { if ($dir == '.' || $dir == '..' || !is_dir("{$base}/{$dir}")) { continue; } if (isset($lists[$dir])) { continue; } $modversion = get_modversion($dir); if ($modversion == false) { continue; } $mlist[$dir] = array('name' => $modversion['name'] . " " . $modversion['version'], 'pname' => $dir, 'pversion' => '', 'dtime' => 0, 'vcheck' => $dir); } ksort($mlist); global $xoopsDB; $llist = array(); $que = ""; foreach ($mlist as $dir => $v) { $hash = md5_file(XOOPS_ROOT_PATH . "/modules/{$dir}/xoops_version.php"); $res = $xoopsDB->query("SELECT pkgref FROM " . UPDATE_FILE . " WHERE hash=" . $xoopsDB->quoteString($hash) . " AND path LIKE '%/xoops_version.php'"); if ($xoopsDB->getRowsNum($res)) { // find package list($pkgid) = $xoopsDB->fetchRow($res); $res = $xoopsDB->query("SELECT * FROM " . UPDATE_PKG . " WHERE pkgid={$pkgid}"); $data = $xoopsDB->fetchArray($res); if ($data['vcheck'] == '') { continue; } // include base module $v['pname'] = $data['pname']; $v['pversion'] = $data['pversion']; $v['dtime'] = $data['dtime']; $lists[$dir] = $v; } else { $que .= "{$hash} {$dir}\n"; $llist[$hash] = $v; } } if ($que) { $server = get_update_server(); if (!empty($server)) { $url = $server . "list2.php"; $list = file_get_url($url, 'list', array('que' => $que), 0); if (empty($list)) { foreach (preg_split('/\\n/', $list) as $ln) { $pkg = pkg_info_csv($ln); $hash = $pkg['delegate']; if (isset($llist[$hash])) { $pkg['dirname'] = $dir = $llist[$hash]['vcheck']; unset($llist[$hash]); $lists[$dir] = $pkg; } } } } } ksort($lists); foreach ($llist as $v) { $lists[$v['vcheck']] = $v; } closedir($dh); return $lists; }
/** * Renders a particular view for an attribute */ public function render($view, $return = false) { if ($return) { ob_start(); } Loader::element(DIRNAME_ATTRIBUTES . '/' . $view . '_header', array('type' => $this->attributeType)); $js = $this->attributeType->getAttributeTypeFileURL($view . '.js'); $css = $this->attributeType->getAttributeTypeFileURL($view . '.css'); $html = Loader::helper('html'); if ($js != false) { $this->controller->addHeaderItem($html->javascript($js)); } if ($css != false) { $this->controller->addHeaderItem($html->css($css)); } $this->controller->setupAndRun($view); extract($this->controller->getSets()); extract($this->controller->getHelperObjects()); $atHandle = $this->attributeType->getAttributeTypeHandle(); if (is_object($attributeKey)) { $this->controller->set('akID', $this->attributeKey->getAttributeKeyID()); } if (file_exists(DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php')) { $file = DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php'; } if (!isset($file) && $this->attributeType->getPackageID() > 0) { $pkgHandle = PackageList::getHandle($this->attributeType->getPackageID()); $dirp = is_dir(DIR_PACKAGES . '/' . $pkgHandle) ? DIR_PACKAGES . '/' . $pkgHandle : DIR_PACKAGES_CORE . '/' . $pkgHandle; if (file_exists($dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php')) { $file = $dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php'; } } if (!isset($file)) { if (file_exists(DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php')) { $file = DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $view . '.php'; } } if (isset($file)) { include $file; } Loader::element(DIRNAME_ATTRIBUTES . '/' . $view . '_footer', array('type' => $this->attributeType)); if ($return) { $contents = ob_get_contents(); ob_end_clean(); return $contents; } }
private 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); } 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(); $bv->setBlockObject($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->baseURL = DIR_REL . '/' . 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->baseURL = ASSETS_URL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle() . '/' . DIRNAME_BLOCK_TEMPLATES . '/' . $bFilename; } // 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(); $bv->setBlockObject($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 = DIR_REL . '/' . DIRNAME_BLOCKS . '/' . $obj->getBlockTypeHandle(); } if (!isset($template)) { $bv = new BlockView(); $bv->setBlockObject($obj); $template = $bv->getBlockPath($this->render) . '/' . $this->render; $this->baseURL = $bv->getBlockURL(); } if ($this->basePath == '') { $this->basePath = dirname($template); } $this->template = $template; }
protected function mapAttributeTypeFilePath($_file) { $atHandle = $this->atHandle; if (file_exists(DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file)) { $file = DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file; $url = BASE_URL . DIR_REL . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file; } else if ($_file == FILENAME_ATTRIBUTE_CONTROLLER && file_exists(DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '.php')) { $file = DIR_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '.php'; } $pkgID = $this->pkgID; if (!isset($file) && $pkgID > 0) { $pkgHandle = PackageList::getHandle($pkgID); $dirp = is_dir(DIR_PACKAGES . '/' . $pkgHandle) ? DIR_PACKAGES . '/' . $pkgHandle : DIR_PACKAGES_CORE . '/' . $pkgHandle; if (file_exists($dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file)) { $file = $dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file; $url = BASE_URL . DIR_REL . '/' .DIRNAME_PACKAGES. '/' .$pkgHandle . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file; } else if ($_file == FILENAME_ATTRIBUTE_CONTROLLER && file_exists($dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '.php')) { $file = $dirp . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '.php'; } } if (!isset($file)) { if (file_exists(DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file)) { $file = DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file; $url = ASSETS_URL . '/' . DIRNAME_MODELS . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '/' . $_file; } else if ($_file == FILENAME_ATTRIBUTE_CONTROLLER && file_exists(DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '.php')) { $file = DIR_MODELS_CORE . '/' . DIRNAME_ATTRIBUTES . '/' . DIRNAME_ATTRIBUTE_TYPES . '/' . $atHandle . '.php'; } } if (isset($file)) { $obj = new stdClass; $obj->file = $file; $obj->url = $url; return $obj; } else { return false; } }
/** * Gets the custom templates available for the current BlockType * @return array an array of strings */ function getBlockTypeCustomTemplates() { $btHandle = $this->getBlockTypeHandle(); $pkgHandle = $this->getPackageHandle(); $templates = array(); $fh = Loader::helper('file'); if (file_exists(DIR_FILES_BLOCK_TYPES . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES)) { $templates = array_merge($templates, $fh->getDirectoryContents(DIR_FILES_BLOCK_TYPES . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES)); } /* if ($pkgHandle != null) { if (is_dir(DIR_PACKAGES . '/' . $pkgHandle)) { $templates = array_merge($templates, $fh->getDirectoryContents(DIR_PACKAGES . "/{$pkgHandle}/" . DIRNAME_BLOCKS . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES)); } else { $templates = array_merge($templates, $fh->getDirectoryContents(DIR_PACKAGES_CORE . "/{$pkgHandle}/" . DIRNAME_BLOCKS . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES)); } } */ // NOW, we check to see if this btHandle has any custom templates that have been installed as separate packages $pl = PackageList::get(); $packages = $pl->getPackages(); foreach($packages as $pkg) { $d = (is_dir(DIR_PACKAGES . '/' . $pkg->getPackageHandle())) ? DIR_PACKAGES . '/'. $pkg->getPackageHandle() : DIR_PACKAGES_CORE . '/'. $pkg->getPackageHandle(); if (is_dir($d . '/' . DIRNAME_BLOCKS . '/' . $btHandle . '/' . DIRNAME_BLOCK_TEMPLATES)) { $templates = array_merge($templates, $fh->getDirectoryContents($d . '/' . DIRNAME_BLOCKS . '/' . $btHandle . '/' . DIRNAME_BLOCK_TEMPLATES)); } } if (file_exists(DIR_FILES_BLOCK_TYPES_CORE . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES)) { $templates = array_merge($templates, $fh->getDirectoryContents(DIR_FILES_BLOCK_TYPES_CORE . "/{$btHandle}/" . DIRNAME_BLOCK_TEMPLATES)); } $templates = array_unique($templates); return $templates; }
/** Changes the currently active locale * @param string $locale The locale to activate (for example: 'en_US') * @param bool $coreOnly = false Set to true to load only the core translation files, set to false (default) to load also packages and site locale translations */ public function setLocale($locale, $coreOnly = false) { $localeNeededLoading = false; if ($locale == 'en_US' && !ENABLE_TRANSLATE_LOCALE_EN_US) { if (isset($this->translate)) { unset($this->translate); } return; } if (is_dir(DIR_LANGUAGES . '/' . $locale)) { $languageDir = DIR_LANGUAGES . '/' . $locale; } elseif (is_dir(DIR_LANGUAGES_CORE . '/' . $locale)) { $languageDir = DIR_LANGUAGES_CORE . '/' . $locale; } else { return; } $options = array('adapter' => 'gettext', 'content' => $languageDir, 'locale' => $locale, 'disableNotices' => true, 'ignore' => array('.', 'messages.po')); if (defined('TRANSLATE_OPTIONS')) { $_options = unserialize(TRANSLATE_OPTIONS); if (is_array($_options)) { $options = array_merge($options, $_options); } } if (!isset($this->translate)) { $this->translate = new Zend_Translate($options); $localeNeededLoading = true; } else { if (!in_array($locale, $this->translate->getList())) { $this->translate->addTranslation($options); $localeNeededLoading = true; } $this->translate->setLocale($locale); } if (!$coreOnly) { $this->addSiteInterfaceLanguage($locale); global $config_check_failed; if (!(isset($config_check_failed) && $config_check_failed)) { foreach (PackageList::get(1)->getPackages() as $p) { $pkg = Loader::package($p->getPackageHandle()); if (is_object($pkg)) { $pkg->setupPackageLocalization($locale, null, $this->translate); } } } } if ($localeNeededLoading) { Events::fire('on_locale_load', $locale); } }
public static function setupSiteInterfaceLocalization() { // don't translate dashboard pages $c = Page::getCurrentPage(); if ($c instanceof Page && Loader::helper('section', 'multilingual')->section('dashboard')) { return; } $ms = MultilingualSection::getCurrentSection(); if (is_object($ms)) { $locale = $ms->getLocale(); } else { $locale = DefaultLanguageHelper::getSessionDefaultLocale(); } // change core language to translate e.g. core blocks/themes if (strlen($locale)) { Localization::changeLocale($locale); } // site translations if (is_dir(DIR_LANGUAGES_SITE_INTERFACE)) { if (file_exists(DIR_LANGUAGES_SITE_INTERFACE . '/' . $locale . '.mo')) { $loc = Localization::getInstance(); $loc->addSiteInterfaceLanguage($locale); } } // add package translations if (strlen($locale)) { $ms = MultilingualSection::getByLocale($locale); if ($ms instanceof MultilingualSection) { $pl = PackageList::get(); $installed = $pl->getPackages(); foreach ($installed as $pkg) { if ($pkg instanceof Package) { $pkg->setupPackageLocalization($ms->getLocale()); } } } } }
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); $ovHelpers = $fh->getDirectoryContents(DIR_HELPERS); $ovJobs = $fh->getDirectoryContents(DIR_FILES_JOBS); $ovCSS = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_CSS); $ovJS = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_JAVASCRIPT); $ovLng = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_LANGUAGES); $ovLibs = $fh->getDirectoryContents(DIR_LIBRARIES); $ovMail = $fh->getDirectoryContents(DIR_FILES_EMAIL_TEMPLATES); $ovModels = $fh->getDirectoryContents(DIR_MODELS); $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 ($ovHelpers as $ovb) { $overrides[] = DIRNAME_HELPERS . '/' . $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 ($ovLibs as $ovb) { $overrides[] = DIRNAME_LIBRARIES . '/' . $ovb; } foreach ($ovMail as $ovb) { $overrides[] = DIRNAME_MAIL_TEMPLATES . '/' . $ovb; } foreach ($ovModels as $ovb) { $overrides[] = DIRNAME_MODELS . '/' . $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", ENABLE_BLOCK_CACHE ? 'On' : 'Off'); $environmentMessage .= sprintf("Overrides Cache - %s\n", ENABLE_OVERRIDE_CACHE ? 'On' : 'Off'); $environmentMessage .= sprintf("Full Page Caching - %s\n", FULL_PAGE_CACHE_GLOBAL == 'blocks' ? 'On - If blocks on the particular page allow it.' : (FULL_PAGE_CACHE_GLOBAL == 'all' ? 'On - In all cases.' : 'Off')); if (FULL_PAGE_CACHE_GLOBAL) { $environmentMessage .= sprintf("Full Page Cache Lifetime - %s\n", FULL_PAGE_CACHE_LIFETIME == 'default' ? sprintf('Every %s (default setting).', Loader::helper('date')->describeInterval(CACHE_LIFETIME)) : (FULL_PAGE_CACHE_LIFETIME == 'forever' ? 'Only when manually removed or the cache is cleared.' : sprintf('Every %s minutes.', Config::get('FULL_PAGE_CACHE_LIFETIME_CUSTOM')))); } $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(); } else { if (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"; } else { if (is_string($key)) { $environmentMessage .= "{$key} - {$val}\n"; } else { $environmentMessage .= "{$val}\n"; } } } } print $environmentMessage; exit; }
/** * 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)); } Loader::library('template_file'); $templates = array(); foreach (array_unique($files) as $file) { $templates[] = new TemplateFile($this, $file); } return TemplateFile::sortTemplateFileList($templates); }
public function get_environment_info() { set_time_limit(5); $environmentMessage = '# ' . t('concrete5 Version') . "\n" . APP_VERSION . "\n\n"; $environmentMessage .= '# ' . t('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 .= t('None') . "\n"; } $environmentMessage .= "\n"; // overrides $environmentMessage .= '# ' . t('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); $ovHelpers = $fh->getDirectoryContents(DIR_HELPERS); $ovJobs = $fh->getDirectoryContents(DIR_FILES_JOBS); $ovCSS = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_CSS); $ovJS = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_JAVASCRIPT); $ovLng = $fh->getDirectoryContents(DIR_BASE . '/' . DIRNAME_LANGUAGES); $ovLibs = $fh->getDirectoryContents(DIR_LIBRARIES); $ovMail = $fh->getDirectoryContents(DIR_FILES_EMAIL_TEMPLATES); $ovModels = $fh->getDirectoryContents(DIR_MODELS); $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 ($ovHelpers as $ovb) { $overrides[] = DIRNAME_HELPERS . '/' . $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 ($ovLibs as $ovb) { $overrides[] = DIRNAME_LIBRARIES . '/' . $ovb; } foreach ($ovMail as $ovb) { $overrides[] = DIRNAME_MAIL_TEMPLATES . '/' . $ovb; } foreach ($ovModels as $ovb) { $overrides[] = DIRNAME_MODELS . '/' . $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 .= t('None') . "\n"; } $environmentMessage .= "\n"; print $environmentMessage; $environmentMessage = '# ' . t('Server Software') . "\n" . $_SERVER['SERVER_SOFTWARE'] . "\n\n"; $environmentMessage .= '# ' . t('Server API') . "\n" . php_sapi_name() . "\n\n"; $environmentMessage .= '# ' . t('PHP Version') . "\n" . PHP_VERSION . "\n\n"; $environmentMessage .= '# ' . t('PHP Extensions') . "\n"; if (function_exists('get_loaded_extensions')) { $gle = @get_loaded_extensions(); natcasesort($gle); $environmentMessage .= implode(', ', $gle); $environmentMessage .= ".\n"; } else { $environmentMessage .= t('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(); } else { if (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# " . t('PHP Settings') . "\n"; foreach ($phpinfo as $name => $section) { foreach ($section as $key => $val) { if (!preg_match('/.*limit.*/', $key) && !preg_match('/.*safe.*/', $key) && !preg_match('/.*max.*/', $key)) { continue; } if (is_array($val)) { $environmentMessage .= "{$key} - {$val['0']}\n"; } else { if (is_string($key)) { $environmentMessage .= "{$key} - {$val}\n"; } else { $environmentMessage .= "{$val}\n"; } } } } print $environmentMessage; exit; }
public static function getJobObjByHandle($jHandle = '', $jobData = array()) { $jcl = Job::jobClassLocations(); //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)) { require_once $path; $className = Object::camelcase($jHandle); $j = new $className(); $j->jHandle = $jHandle; if (intval($jobData['jID']) > 0) { $j->jID = intval($jobData['jID']); $j->jStatus = $jobData['jStatus']; $j->jDateLastRun = $jobData['jDateLastRun']; $j->jLastStatusText = $jobData['jLastStatusText']; $j->pkgID = $jobData['pkgID']; $j->jDateInstalled = $jobData['jDateInstalled']; $j->jNotUninstallable = $jobData['jNotUninstallable']; } return $j; } } return NULL; }
public static function getJobObjByHandle( $jHandle='', $jobData=array() ){ $jcl = Job::jobClassLocations(); //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) ){ require_once($path); $className=Object::camelcase( $jHandle ); $j = new $className(); $j->jHandle=$jHandle; if(intval($jobData['jID'])>0){ $j->setPropertiesFromArray($jobData); } return $j; } } return NULL; }
public function getPackageHandle() { return PackageList::getHandle($this->pkgID); }
public function upgradeCoreData() { $db = Loader::db(); $p1 = Loader::package($this->getPackageHandle()); $v = array($p1->getPackageName(), $p1->getPackageDescription(), $p1->getPackageVersion(), $this->getPackageID()); $db->query("update Packages set pkgName = ?, pkgDescription = ?, pkgVersion = ? where pkgID = ?", $v); PackageList::refreshCache(); }
/** * @return Package */ public function install() { PackageList::refreshCache(); $db = Loader::db(); $dh = Loader::helper('date'); $v = array($this->getPackageName(), $this->getPackageDescription(), $this->getPackageVersion(), $this->getPackageHandle(), 1, $dh->getSystemDateTime()); $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; }
function reg_set_packages() { global $xoopsDB; $active = get_active_list(); $pkgs = get_packages('all'); if (file_exists(ROLLBACK)) { unlink(ROLLBACK); } // expired $del = "DELETE FROM " . UPDATE_PKG . " WHERE pkgid=%u"; $sel = "SELECT pkgid FROM " . UPDATE_PKG . " WHERE vcheck=%s AND pversion='HEAD'"; $succ = 0; $pnames = isset($_POST['pname']) ? $_POST['pname'] : array(); foreach ($pkgs as $pkg) { $dirname = $pkg['vcheck']; if (array_search($dirname, $active)) { $res = $xoopsDB->query(sprintf($sel, $xoopsDB->quoteString($dirname))); $pkgid = 0; if ($xoopsDB->getRowsNum($res) > 0) { list($pkgid) = $xoopsDB->fetchRow($res); } $pname = $pkg['pname']; if ($pkgid && !in_array($dirname, $pnames)) { // unchecked? (removed) if ($xoopsDB->query(sprintf($del, $pkgid))) { $xoopsDB->query("DELETE FROM " . UPDATE_FILE . " WHERE pkgref={$pkgid}"); $succ++; } } clean_pkginfo(); // garbege collection } } $ins = "INSERT INTO " . UPDATE_PKG . "(parent,pname,pversion,vcheck) VALUES(%u,%s,'HEAD',%s)"; foreach ($pnames as $dirname) { if (!in_array($dirname, $active)) { if (isset($pkgs[$dirname])) { $pkg = $pkgs[$dirname]; } else { $pkg = PackageList::selectPackage($dirname); } $par = empty($pkg['pkgid']) ? 0 : $pkg['pkgid']; if (register_detail($pkg['pname'], $dirname)) { $succ++; } } } if ($succ) { clear_get_cache(0, 'list'); } return $succ; }