/** * Execute un script SQL sur la base de test. * * Dans le nom du chemin, la chaîne $drivername est remplacé par le nom du driver. * * @param string $pScriptId Identifer du chemin du script (peut être de la forme "module|fichier"). */ protected function _runSQLScript($pScriptId) { $selector = CopixSelectorFactory::create($pScriptId); $ct = $this->_getConnection(); $filePath = str_replace('$drivername', $ct->getProfile()->getDriverName(), $selector->fileName); $ct->doSQLScript($selector->getPath($filePath), true); }
public function testSimpleRTFTemplate() { $template = CopixClassesFactory::create('genericTools|RTFTemplate'); $template->assign('VARIABLE_1', 'Voici une belle présentation <b>avec des infos importantes</b> ', true); $template->assign('VARIABLE_2', '<ul><li>puce 1</li><li>puce 2</li><li>puce 3</li></ul>', true); $template->assign('VARIABLE_3', 'Contenu simple', true); $codeDuDocumentRTFFinal = $template->fetch('generictools|rtftest.rtf'); $selector = CopixSelectorFactory::create('generictools|rtftest.expectedresult.rtf'); $expectedResultFilePath = $selector->getPath(COPIX_TEMPLATES_DIR) . $selector->fileName; $codeDuDocumentRTFTest = file_get_contents($expectedResultFilePath); CopixFile::write('/tmp/document_sortie.rtf', $codeDuDocumentRTFFinal); $this->assertEquals($codeDuDocumentRTFFinal, $codeDuDocumentRTFTest); }
/** * Récupère dans une chaine de caractère le contenu du RTF * @param $pRTFTemplateFileName Le fichier RTF modèle. * Si le sélecteur donné est de type module, on considère que le fichier rtf est dans "templates" * @return string le fichier RTF transformé */ public function fetch($pRTFTemplateFileName) { $selector = CopixSelectorFactory::create($pRTFTemplateFileName); if (($content = file_get_contents($selector->getPath($selector->type == 'module' ? COPIX_TEMPLATES_DIR : '') . $selector->fileName)) !== false) { preg_match_all('{\\$(\\w+)}', $content, $out); foreach ($out[1] as $nomVariable) { $content = str_replace('\\{$' . $nomVariable . '\\}', isset($this->_data[$nomVariable]) ? $this->_data[$nomVariable] : '', $content); } return $content; } else { return false; } }
/** * creates a new object */ function &create($name) { //Récupération des éléments critiques. $file = CopixSelectorFactory::create($name); $filePath = $file->getPath() . COPIX_CLASSES_DIR . strtolower($file->fileName) . '.class.php'; if (is_readable($filePath)) { require_once $filePath; $fileClass = $file->fileName; return new $fileClass(); } else { trigger_error(CopixI18N::get('copix:copix.error.unfounded.class', $name . '-' . $filePath), E_USER_ERROR); return null; } }
/** * creates a filePath from a given string module|file and from the given * type of the file (zone, template, static) * @param string $fileId "nom de fichier" ou "nom de module|nom de fichier" * @param string $subDir nom de répertoire relatif (en principe une des valeur COPIX_xxx_DIR definie dans project.inc.php) * @param string $extension * @return string chemin du fichier indiqué ou false si inconnu */ function copix_extract_file_path($fileId, $subDir, $extension = '') { $fileInfo = CopixSelectorFactory::create($fileId); $fileName = $fileInfo->fileName; if ($extension != '') { $fileName = strtolower($fileName) . $extension; } $moduleFile = $fileInfo->getPath($subDir) . $fileName; $projectOverloadedFilePath = $fileInfo->getOverloadedPath($subDir); if ($projectOverloadedFilePath !== null) { $projectOverloadedFilePath .= $fileName; if (is_readable($projectOverloadedFilePath)) { return $projectOverloadedFilePath; } } if (is_readable($moduleFile)) { return $moduleFile; } else { return false; } }
/** * gets the correct string, for a given language. * if it can't get the correct language, it will try to gets the string * from the default language. * if both fails, it will raise a fatal_error. */ function get($key, $args = null, $locale = null) { $me =& CopixI18N::instance(); //finds out required lang / coutry if ($locale === null) { $plug =& $GLOBALS['COPIX']['COORD']->getPlugin('i18n'); if ($plug === null) { $lang = $GLOBALS['COPIX']['CONFIG']->default_language; $country = $GLOBALS['COPIX']['CONFIG']->default_country; } else { $lang = $plug->getLang(); $country = $plug->getCountry(); } } else { $ext = explode('_', $locale); if (count($ext) > 1) { $lang = $ext[0]; $country = $ext[1]; } else { $lang = $ext[0]; $country = $ext[0]; } } //Gets the bundle for the given language. $trans =& CopixSelectorFactory::create($key); if (!$trans->isValid) { trigger_error(CopixI18N::get('copix:copix.error.i18n.keyNotExists', $key), E_USER_ERROR); } $messageId = $trans->fileName; $trans->fileName = substr($trans->fileName, 0, strpos($trans->fileName, '.')); $bundle =& $me->getBundle($trans, $lang); //try to get the message from the bundle. $string = $bundle->get($messageId, $country); if ($string === null) { //if the message was not found, we're gonna //use the default language and country. if ($lang == $GLOBALS['COPIX']['CONFIG']->default_language && $country == $GLOBALS['COPIX']['CONFIG']->default_country) { if ($key == 'copix:copix.error.i18n.keyNotExists') { $msg = 'Can\'t find message key (which should actually be THIS message): ' . $key; } else { $msg = CopixI18N::get('copix:copix.error.i18n.keyNotExists', $key); } trigger_error($msg, E_USER_ERROR); } return $me->get($key, $args, $GLOBALS['COPIX']['CONFIG']->default_language . '_' . $GLOBALS['COPIX']['CONFIG']->default_country); } else { //here, we know the message if ($args !== null) { $string = call_user_func_array('sprintf', array_merge($string, $args)); /* // if(is_array($args)){ switch(count($args)){ case 1: $string=sprintf($string,$args[0]); break; case 2: $string=sprintf($string,$args[0],$args[1]); break; case 3: $string=sprintf($string,$args[0],$args[1],$args[2]); break; } // }else // $string=sprintf($string,$args); */ } return $string; } }
/** * sets the value of a parameter */ function set($id, $value) { $select =& CopixSelectorFactory::create($id); if (!$select->isValid) { trigger_error('Invalid selector' . $id, E_USER_ERROR); } $me =& CopixConfig::instance(); $group =& $me->_getGroupConfig($select->getQualifier()); return $group->set($id, $value); }
/** * Charge la valeurs des paramètres depuis le fichier XML * @return void */ private function _loadFromXML() { $module = $this->module === "|" ? "default" : substr($this->module, 0, -1); $select = CopixSelectorFactory::create($this->module . 'module.xml'); //checks if the file exists $fileName = $select->getPath($select->fileName); if (!is_readable($fileName)) { return false; } $this->_configVars = array(); $xml = simplexml_load_file($fileName); if (isset($xml->parameters->parameter) || isset($xml->parameters->group)) { // nodes parameter sans group if (isset($xml->parameters->parameter)) { $this->_xmlParameters[$this->module]['no-group'] = $xml->parameters->parameter; foreach ($xml->parameters->parameter as $key => $child) { $this->_loadParameterFromNode($module, $child); } } // nodes parameter dans un group if (isset($xml->parameters->group)) { $temp = 0; foreach ($xml->parameters->group as $groupKey => $groupChild) { $attributes = $groupChild->attributes(); if (isset($attributes['caption'])) { $groupName = (string) $attributes['caption']; } elseif (isset($attributes['captioni18n'])) { CopixContext::push($module); $groupName = _i18n((string) $attributes['captioni18n']); CopixContext::pop(); } else { throw new CopixException(_i18n('copix:copixmodule.error.parametersGroupCaptionEmpty', array($module))); } $this->_xmlParameters[$this->module][$groupName] = $groupChild; foreach ($groupChild as $key => $child) { $this->_loadParameterFromNode($module, $child); } $temp++; } } } //echo '<pre>'; //print_r ($this->_xmlParameters); }
public function processDefault() { ini_set('max_execution_time', 0); $classeurservice =& CopixClassesFactory::Create('classeur|classeurservice'); /* DEBUG if (!Admin::canAdmin()) return CopixActionGroup::process ('genericTools|Messages::getError', array ('message'=>CopixI18N::get ('kernel|kernel.error.noRights'), 'back'=>CopixUrl::get ())); */ $tpl = new CopixTpl(); // $tpl->assign ('TITLE_PAGE', CopixI18N::get ('sysutils|admin.menu.cache')); // $tpl->assign ('MENU', Admin::getMenu('cache')); /////////////// //// ALBUM //// /////////////// $sql = "\n SELECT\n A.id AS album_id, A.nom AS album_nom, A.prefs AS album_prefs, A.date AS album_date, A.cle AS album_cle, A.public AS album_public\n FROM module_album_albums A\n ORDER BY A.id\n "; $album_list = _doQuery($sql); $album_tree = array(); foreach ($album_list as $album_item) { if (!isset($album_tree[$album_item->album_id])) { $album_tree[$album_item->album_id] = new CopixPPO(); $album_tree[$album_item->album_id]->info = $album_item; $parent = Kernel::getModParent("MOD_ALBUM", $album_item->album_id); if (!$parent) { unset($album_tree[$album_item->album_id]); continue; } $album_tree[$album_item->album_id]->parent = $parent[0]; $album_tree[$album_item->album_id]->dossier = array(); $album_tree[$album_item->album_id]->photo = array(); } $root = $this->albumScanFolder($album_item->album_id, 0); $album_tree[$album_item->album_id]->dossier = $root->dossier; $album_tree[$album_item->album_id]->photo = $root->photo; } // module_malle_malles : id titre date_creation cle // module_malle_folders : id malle parent nom nb_folders nb_files taille date_creation // module_malle_files : id malle folder nom fichier taille type cle date_upload /////////////// //// MALLE //// /////////////// $sql = "\n SELECT\n id, titre, date_creation, cle\n FROM module_malle_malles\n ORDER BY id\n "; $malle_list = _doQuery($sql); $malle_tree = array(); foreach ($malle_list as $malle_item) { if (!isset($malle_tree[$malle_item->id])) { $malle_tree[$malle_item->id] = new CopixPPO(); $malle_tree[$malle_item->id]->info = $malle_item; $parent = Kernel::getModParent("MOD_MALLE", $malle_item->id); if (!$parent) { unset($malle_tree[$malle_item->id]); continue; } $malle_tree[$malle_item->id]->parent = $parent[0]; $user_parents = Kernel::getNodeParents($parent[0]->node_type, $parent[0]->node_id); $malle_tree[$malle_item->id]->user_parents = $user_parents; $malle_tree[$malle_item->id]->dossier = array(); $malle_tree[$malle_item->id]->docs = array(); } $root = $this->malleScanFolder($malle_item->id, 0); $malle_tree[$malle_item->id]->dossier = $root->dossier; $malle_tree[$malle_item->id]->docs = $root->docs; } ///////////////////////////////////// ///////////////////////////////////// // kernel_mod_enabled : node_type node_id module_type module_id // module_classeur : id titre cle date_creation date_publication public // module_classeur_dossier : id module_classeur_id parent_id nom nb_dossiers nb_fichiers taille cle date_creation user_type user_id date_publication public // module_classeur_fichier : id module_classeur_id module_classeur_dossier_id titre commentaire fichier taille type cle date_upload user_type user_id // IMPORT ALBUMS if (1) { foreach ($album_tree as $album_item) { if (!isset($album_item->parent->node_type)) { continue; } //// RECHERCHE D'UN CLASSEUR EXISTANT $sql = "\n SELECT module_id\n FROM kernel_mod_enabled\n WHERE node_type=:node_type AND node_id=:node_id AND module_type=:module_type\n "; $param = array('node_type' => $album_item->parent->node_type, 'node_id' => $album_item->parent->node_id, 'module_type' => 'MOD_CLASSEUR'); $mod_classeur = _doQuery($sql, $param); if (!isset($mod_classeur[0])) { $node_infos = $this->getNodeInfos($album_item->parent->node_type, $album_item->parent->node_id); $file =& CopixSelectorFactory::create("classeur|classeur"); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; $modservice =& CopixClassesFactory::Create('classeur|kernelclasseur'); if (method_exists($modservice, "create")) { $modid = $modservice->create(array('title' => $node_infos->nom, 'subtitle' => '', 'node_type' => $album_item->parent->node_type, 'node_id' => $album_item->parent->node_id)); if ($modid != null) { Kernel::registerModule('MOD_CLASSEUR', $modid, $album_item->parent->node_type, $album_item->parent->node_id); } } $classeur_id = $modid; } else { $classeur_id = $mod_classeur[0]->module_id; } $classeurDAO = _ioDAO('classeur|classeur'); $classeur = $classeurDAO->get($classeur_id); $new_dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/'; if (!file_exists($new_dir)) { mkdir($new_dir, 0755, true); } //// CREATION D'UN DOSSIER D'IMPORT $dossierDAO = _ioDAO('classeur|classeurdossier'); $dossier = _record('classeur|classeurdossier'); $dossier->classeur_id = $classeur_id; $dossier->parent_id = 0; $dossier->nom = "Import Album " . $album_item->info->album_id; $dossier->cle = $album_item->info->album_cle; $dossier->date_creation = $album_item->info->album_date; $dossier->user_type = ""; $dossier->user_id = ""; $dossier->nb_dossiers = 0; $dossier->nb_fichiers = 0; $dossier->taille = 0; $dossier->casier = 0; $dossierDAO->insert($dossier); // $dossier->id $this->albumImport($album_item, $dossier); $classeurservice->updateFolderInfosWithDescendants($dossier); } } // IMPORT MALLES if (1) { foreach ($malle_tree as $malle_item) { if (!isset($malle_item->parent->node_type)) { continue; } //// RECHERCHE D'UN CLASSEUR EXISTANT $sql = "\n SELECT module_id\n FROM kernel_mod_enabled\n WHERE node_type=:node_type AND node_id=:node_id AND module_type=:module_type\n "; $param = array('node_type' => $malle_item->parent->node_type, 'node_id' => $malle_item->parent->node_id, 'module_type' => 'MOD_CLASSEUR'); $mod_classeur = _doQuery($sql, $param); if (!isset($mod_classeur[0])) { $node_infos = $this->getNodeInfos($malle_item->parent->node_type, $malle_item->parent->node_id); $file =& CopixSelectorFactory::create("classeur|classeur"); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; $modservice =& CopixClassesFactory::Create('classeur|kernelclasseur'); if (method_exists($modservice, "create")) { $modid = $modservice->create(array('title' => $node_infos->nom, 'subtitle' => '', 'node_type' => $malle_item->parent->node_type, 'node_id' => $malle_item->parent->node_id)); if ($modid != null) { Kernel::registerModule('MOD_CLASSEUR', $modid, $malle_item->parent->node_type, $malle_item->parent->node_id); } } $classeur_id = $modid; } else { $classeur_id = $mod_classeur[0]->module_id; } $classeurDAO = _ioDAO('classeur|classeur'); $classeur = $classeurDAO->get($classeur_id); $new_dir = realpath('./static/classeur') . '/' . $classeur->id . '-' . $classeur->cle . '/'; if (!file_exists($new_dir)) { mkdir($new_dir, 0755, true); } //// CREATION D'UN DOSSIER D'IMPORT $dossierDAO = _ioDAO('classeur|classeurdossier'); $dossier = _record('classeur|classeurdossier'); $dossier->classeur_id = $classeur_id; $dossier->parent_id = 0; $dossier->nom = "Import documents " . $malle_item->info->id; $dossier->cle = $malle_item->info->cle; $dossier->date_creation = $malle_item->info->date_creation; $dossier->user_type = ""; $dossier->user_id = ""; $dossier->nb_dossiers = 0; $dossier->nb_fichiers = 0; $dossier->taille = 0; $dossierDAO->insert($dossier); // $dossier->id $this->malleImport($malle_item, $dossier); $classeurservice->updateFolderInfosWithDescendants($dossier); } } $sql = "\n UPDATE kernel_mod_available\n SET node = CONCAT(node, '_OFF')\n WHERE module = 'MOD_MALLE' OR module = 'MOD_ALBUM'"; _doQuery($sql); $sql = "\n UPDATE kernel_mod_enabled\n SET node_type = CONCAT(node_type, '_OFF')\n WHERE module_type = 'MOD_MALLE' OR module_type = 'MOD_ALBUM' AND node_type != 'MOD_TELEPROCEDURES'"; _doQuery($sql); echo "<h1>Fin</h1>"; echo "<pre>"; print_r($album_tree); print_r($malle_tree); die; }
/** * Récupération du nom du DAO record à partir de son identifiant * @param string $DAOid l'identifiant du DAO * @return string */ public static function getDAORecordName($DAOid, $pGenerated = true) { return ($pGenerated === true ? 'Compiled' : '') . 'DAORecord' . CopixSelectorFactory::create($DAOid)->fileName; }
/** * gets the correct string, for a given language. * if it can't get the correct language, it will try to gets the string * from the default language. * if both fails, it will raise a fatal_error. */ function get($key, $args = null, $locale = null) { $me =& CopixI18N::instance(); //finds out required lang / coutry if ($locale === null) { $lang = $GLOBALS['COPIX']['CONFIG']->default_language; // rempli par le plugin egalement $country = $GLOBALS['COPIX']['CONFIG']->default_country; } else { $ext = explode('_', $locale); if (count($ext) > 1) { $lang = $ext[0]; $country = $ext[1]; } else { $lang = $ext[0]; $country = $ext[0]; } } //Gets the bundle for the given language. $keySelector = substr($key, 0, strpos($key, '.')); $trans =& CopixSelectorFactory::create($keySelector); if (!$trans->isValid) { trigger_error(CopixI18N::get('copix:copix.error.i18n.keyNotExists', $key), E_USER_ERROR); } $key = $me->_extractMessageKey($key); $bundle =& $me->getBundle($trans, $lang); //try to get the message from the bundle. $string = $bundle->get($key, $country); if ($string === null) { //if the message was not found, we're gonna //use the default language and country. if ($lang == $GLOBALS['COPIX']['CONFIG']->default_language && $country == $GLOBALS['COPIX']['CONFIG']->default_country) { if ($key == 'copix:copix.error.i18n.keyNotExists') { $msg = 'Can\'t find message key (which should actually be THIS message): ' . $key; } else { $msg = CopixI18N::get('copix:copix.error.i18n.keyNotExists', $key); } trigger_error($msg, E_USER_ERROR); } return $me->get($key, $args, $GLOBALS['COPIX']['CONFIG']->default_language . '_' . $GLOBALS['COPIX']['CONFIG']->default_country); } else { //here, we know the message if ($args !== null) { $string = call_user_func_array('sprintf', array_merge($string, $args)); } return $string; } }
/** * Force le contexte au contexte de tplId et indique si le contexte à été * modifié dans la variable de retour. * @param string $pTplId le template dont on souhaites forcer le contexte * @return boolean si nous avons bien mis à jour le contexte (pour que l'appelant puisse * savoir s'il faudra rétablir le contexte ou non) */ private function _pushContext($pTplId) { try { $tpl = CopixSelectorFactory::create($pTplId); if ($tpl->type == 'module') { CopixContext::push($tpl->module); return true; } } catch (Exception $e) { return false; } }
/** * same as create, but handles the singleton pattern. * @param $id the id of the object we wants to get. */ function &_instanceOf($id) { //gets the fileSelctor $file =& CopixSelectorFactory::create($id); //check if exists in the cache (while getting the fullIdentifier in id) if (!isset($this->_cacheInstance[$id = $file->getSelector()])) { $this->_cacheInstance[$id] =& $this->create($id); } return $this->_cacheInstance[$id]; }
/** * Résouds la référence à une classe ou une instance. * * @param string $pClassName Classe de l'objet. * @param string $pFileName Nom du fichier. * @param object $pObject Instance de l'objet. * @return array L'information de référence. */ private static function _resolveReference($pClassName, $pFileName = null, $pObject = null) { if (isset(self::$_globalReferences[$pClassName])) { return self::$_globalReferences[$pClassName]; } // Classe "anonyme" ou autoloadée if (strtolower($pClassName) == 'stdclass' || CopixAutoloader::canAutoload($pClassName)) { return self::$_globalReferences[$pClassName] = false; } $class = new ReflectionClass($pClassName); // DAO ou enregistrement DAO if ((class_exists('ICopixDAORecord', false) && $class->implementsInterface('ICopixDAORecord') || class_exists('ICopixDAO', false) && $class->implementsInterface('ICopixDAO')) && ($pFileName !== null || $pObject !== null)) { return self::$_globalReferences[$pClassName] = array(self::DAO, $pFileName === null ? $pObject->getDAOId() : $pFileName, null); } // On a un nom de fichier passé par l'utilisateur if ($pFileName !== null) { // Le fichier est lisible, on ne cherche pas plus loin if (is_readable($pFileName)) { return self::$_globalReferences[$pClassName] = array(self::FILE, $pFileName); } // Si ça ressemble à un sélecteur Copix, on vérifie. if (preg_match('/^\\w+\\|\\w+$/', $pFileName)) { $selector = CopixSelectorFactory::create($pFileName); $filePath = $selector->getPath(COPIX_CLASSES_DIR . strtolower($selector->fileName) . '.class.php'); if (is_readable($filePath)) { return self::$_globalReferences[$pClassName] = array(self::MODULE_CLASS, $pFileName); } } // Ca n'a pas marché } // On a rien... essayons de deviner $type = self::FILE; $fileName = $class->getFileName(); // Vérifie si ça correpond à une classe de module if (preg_match(self::$_moduleClassRegex, $fileName, $parts)) { list(, $basePath, $moduleName, $className) = $parts; if (CopixModule::isValid($moduleName, $basePath)) { // Bingo return self::$_globalReferences[$pClassName] = array(self::MODULE_CLASS, $moduleName . '|' . $className); } } // En dernier recours, stocke un fichier return self::$_globalReferences[$pClassName] = array($type, $fileName); }
/** * Retourne le sélecteur de DAO (utile pour les générations complètes de clefs i18n) * @return string */ public function getQualifier() { return CopixSelectorFactory::create($this->_DAOId)->getQualifier(); }
/** * instancie les différents objets pour le rendu des elements inline et bloc. */ function CopixWikiRenderer($config = null) { if (is_null($config)) { $this->config =& new CopixWikiRendererConfig(); } else { if (is_object($config)) { $this->config = $config; } else { $fs = CopixSelectorFactory::create($config); if ($fs === null) { $this->config =& new CopixWikiRendererConfig(); } else { require_once $fs->getPath('config/') . strtolower($fs->fileName) . '.conf.php'; $name = $fs->fileName; $this->config =& new $name(); } } } $this->_currentBloc = new CopixWikiRendererBloc($this); // bloc 'fantome' $this->inlineParser =& new CopixWikiInlineParser($this->config->inlinetags, $this->config->simpletags, $this->config->inlineTagSeparator, $this->config->checkWikiWord, $this->config->checkWikiWordFunction); foreach ($this->config->bloctags as $name => $ok) { $name = 'WRB_' . $name; if ($ok) { $this->_blocList[] =& new $name($this); } } }
/** * compile the given class id. */ function compile($DAOid) { // recuperation du chemin et nom de fichier de definition xml de la dao $this->_DAOid = $DAOid; $selector =& CopixSelectorFactory::create($this->_DAOid); if (!$selector->isValid) { trigger_error(CopixI18N::get('dao.error.selector.invalid', $this->_DAOid), E_USER_ERROR); } $this->_baseName = $selector->fileName; $this->_shortFileName = strtolower($selector->fileName . '.dao.definition.xml'); $fileName = $selector->getPath(COPIX_RESOURCES_DIR) . $this->_shortFileName; if (!(is_file($fileName) && is_readable($fileName))) { trigger_error(CopixI18N::get('copix:dao.error.definitionfile.unknow', $fileName), E_USER_ERROR); } // chargement du fichier XML require_once COPIX_UTILS_PATH . 'CopixSimpleXml.class.php'; $xmlParser =& new CopixSimpleXML(); $parsedFile = $xmlParser->parseFile($fileName); // chargement de l'analyseur de définition et du générateur de code, adéquate à la version de la dao $attr = $parsedFile->attributes(); $version = 1; if (isset($attr['VERSION'])) { $version = intval($attr['VERSION']); } if ($version == 1) { require_once COPIX_DAO_PATH . 'CopixDAODefinitionV1.class.php'; require_once COPIX_DAO_PATH . 'CopixDAOGeneratorV1.class.php'; $userDefinition =& new CopixDAODefinitionV1($this); $generator =& new CopixDAOGeneratorV1($this); } else { require_once COPIX_DAO_PATH . 'CopixDAODefinitionV0.class.php'; require_once COPIX_DAO_PATH . 'CopixDAOGeneratorV0.class.php'; $userDefinition =& new CopixDAODefinitionV0($this); $generator =& new CopixDAOGeneratorV0($this); } // analyse de la définition $userDefinition->loadFrom($parsedFile); // inclusion des classes "surchargeant" les futures classes générées $DAOPath = $selector->getPath(COPIX_CLASSES_DIR) . strtolower($selector->fileName . '.dao.class.php'); //echo '$DAOPath : '. $DAOPath .'<br>'; if (is_readable($DAOPath)) { require_once $DAOPath; $generator->setUserDAOPath($DAOPath); // eventuelle surcharge de la classe DAO $className = $this->_DAOClassName(); //echo '$this->_DAOClassName : '. $className .'<br>'; if (class_exists($className)) { $generator->setUserDAO(new $className()); } // eventuelle surcharge de la classe du record DAO $className = $this->_DAORecordClassName(); //echo '$this->_DAORecordClassName : '. $className .'<br>'; if (class_exists($className)) { $generator->setUserDAORecord(new $className()); } } $generator->setUserDefinition($userDefinition); // génération des classes PHP correspondant à la définition de la DAO $compiled = '<?php '; $compiled .= $generator->compileDAORecordClass(); $compiled .= $generator->compileDAO(); $compiled .= "\n?>"; $objectWriter =& new CopixFileLocker(); $objectWriter->write(CopixDAOFactory::getCompiledPath($DAOid), $compiled, 'w'); }
/** * creates a filePath from a given string module|file and from the given * type of the file (zone, template, static) * @param string $fileId "nom de fichier" ou "nom de module|nom de fichier" * @param string $subDir nom de répertoire relatif (en principe une des valeur COPIX_xxx_DIR definie dans project.inc.php) * @param string $extension * @return string chemin du fichier indiqué ou false si inconnu */ function extractFilePath($fileId, $subDir, $extension = '') { $fileInfo =& CopixSelectorFactory::create($fileId); $fileName = $fileInfo->fileName; if ($extension != '') { $fileName = strtolower($fileName) . $extension; } $moduleFile = $fileInfo->getPath($subDir) . $fileName; $projectOverloadedFilePath = $fileInfo->getOverloadedPath($subDir); if ($projectOverloadedFilePath !== null) { $projectOverloadedFilePath .= $fileName; if (is_readable($projectOverloadedFilePath)) { return $projectOverloadedFilePath; } } if (is_readable($moduleFile)) { return $moduleFile; } else { return false; //trigger_error (CopixI18N::get ('copix:copix.error.resolve',$fileId), E_USER_ERROR); return null; } }
/** * Verifie si le blog des teleprocedures d'une ville existe. Si non, le cree. Renvoie son id. * * @author Christophe Beyer <*****@*****.**> * @since 2009/01/23 * @param object $rTelep Recordset de la teleprocedure * @return object Recordset du blog */ public function checkIfBlogExists($rTelep) { $modEnabled = Kernel::getModEnabled('MOD_TELEPROCEDURES', $rTelep->id); $return = null; $exists = false; foreach ($modEnabled as $mod) { if ($mod->module_type == 'MOD_BLOG') { $exists = $mod->module_id; } } if (!$exists) { // Il faut creer le blog $modname = 'blog'; $file =& CopixSelectorFactory::create($modname . "|" . $modname); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; if (is_readable($filePath)) { $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname); if (method_exists($modservice, "create")) { $title = $rTelep->titre . ' - ' . CopixI18N::get('teleprocedures|teleprocedures.moduleDescription'); $modid = $modservice->create(array('title' => $title, 'is_public' => 0)); if ($modid != null) { Kernel::registerModule('MOD_BLOG', $modid, 'MOD_TELEPROCEDURES', $rTelep->id); // Si le blog est cree, on cree aussi la malle et l'album $modname = 'album'; $file =& CopixSelectorFactory::create($modname . "|" . $modname); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; if (is_readable($filePath)) { $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname); if (method_exists($modservice, "create")) { $title = $rTelep->titre . ' - ' . CopixI18N::get('teleprocedures|teleprocedures.moduleDescription'); $mod2id = $modservice->create(array('title' => $title)); if ($mod2id != null) { Kernel::registerModule('MOD_ALBUM', $mod2id, 'MOD_TELEPROCEDURES', $rTelep->id); } } } $modname = 'malle'; $file =& CopixSelectorFactory::create($modname . "|" . $modname); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; if (is_readable($filePath)) { $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname); if (method_exists($modservice, "create")) { $title = $rTelep->titre . ' - ' . CopixI18N::get('teleprocedures|teleprocedures.moduleDescription'); $mod2id = $modservice->create(array('title' => $title)); if ($mod2id != null) { Kernel::registerModule('MOD_MALLE', $mod2id, 'MOD_TELEPROCEDURES', $rTelep->id); } } } } } } } else { $modid = $exists; } if ($modid) { $daoBlog =& _dao('blog|blog'); $return = $daoBlog->get($modid); } return $return; }
/** * gets the bundle for a given language. * @param string $bundleKey la clef du bundle * @param string $lang la langue dans laquelle on veut récupérer le bundle * @return CopixI18NBundle */ public static function getBundle($pBundleKey, $pLang) { $context = CopixContext::get(); if (isset(self::$_bundles[$context][$pBundleKey][$pLang])) { return self::$_bundles[$context][$pBundleKey][$pLang]; } $fileSelector = CopixSelectorFactory::create($pBundleKey); $s = $fileSelector->getSelector(); if (!isset(self::$_bundles[$context][$s][$pLang])) { self::$_bundles[$context][$s][$pLang] = new CopixI18NBundle($fileSelector, $pLang); self::$_bundles[$context][$pBundleKey][$pLang] = self::$_bundles[$context][$s][$pLang]; } return self::$_bundles[$context][$s][$pLang]; }
/** * load from xml */ function _loadFromXML() { require_once COPIX_UTILS_PATH . 'CopixSimpleXml.class.php'; $configFile = $this->group === '|' ? 'project.xml' : 'module.xml'; $select =& CopixSelectorFactory::create($this->group . $configFile); if (!$select->isValid) { trigger_error('Invalid config file'); } //checks if the file exists $fileName = $select->getPath($configFile); if (!is_readable($fileName)) { return false; } $this->_configVars = array(); $parser =& new CopixSimpleXml(); if (!($xml = $parser->parseFile($fileName))) { $parser->raiseError(); } if (isset($xml->PARAMETERS->PARAMETER)) { foreach (is_array($xml->PARAMETERS->PARAMETER) ? $xml->PARAMETERS->PARAMETER : array($xml->PARAMETERS->PARAMETER) as $key => $child) { $attributes = $child->attributes(); //we stores in a key with the following format module|attributeName $this->_configVars[$this->group . $attributes['NAME']] = array('Name' => $attributes['NAME'], 'Caption' => $attributes['CAPTIONI18N'], 'Default' => $attributes['DEFAULT'], 'Value' => $attributes['DEFAULT']); } } }
public function createMissingModules($node_type, $node_id) { $modavailable = Kernel::getModAvailable($node_type); $modenabled = Kernel::getModEnabled($node_type, $node_id, _currentUser()->getExtra('type'), _currentUser()->getExtra('id'), 1); $modinstalled = array(); foreach ($modenabled as $module) { $modinstalled[] = strtolower($module->module_type); } //var_dump($modinstalled); $nodeInfo = Kernel::getNodeInfo($node_type, $node_id); if ($node_type == 'CLUB') { foreach ($modavailable as $module) { // echo "<li>".$module->module_type."</li>"; if ($module->module_type == 'MOD_MAGICMAIL') { $modname = 'magicmail'; // _dump($modinstalled); // if( array_search("mod_magicmail", $modinstalled)===false ) echo "magicmail "; // if( array_search("mod_blog", $modinstalled)!==false ) echo "blog "; if (array_search("mod_magicmail", $modinstalled) === false && array_search("mod_blog", $modinstalled) !== false) { $file =& CopixSelectorFactory::create($modname . "|" . $modname); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; //var_dump($filePath); if (is_readable($filePath)) { $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname); if (method_exists($modservice, "create")) { $subtitle = $node_type == 'BU_ECOLE' && isset($nodeInfo['ALL']->eco_type) ? $nodeInfo['ALL']->eco_type : ''; $prenom = isset($nodeInfo['prenom']) ? $nodeInfo['prenom'] : ''; $modid = $modservice->create(array('title' => trim($prenom . ' ' . $nodeInfo['nom']), 'subtitle' => $subtitle, 'node_type' => $node_type, 'node_id' => $node_id)); if ($modid != null) { // _dump( array( $module->module_type, $modid, $node_type, $node_id )); Kernel::registerModule($module->module_type, $modid, $node_type, $node_id); } } } } } } return false; } foreach ($modavailable as $module) { //var_dump($module); if (preg_match("/^MOD_(.+)\$/", $module->module_type, $modinfo)) { $modname = strtolower($modinfo[1]); if (array_search("mod_" . $modname, $modinstalled) === false) { $file =& CopixSelectorFactory::create($modname . "|" . $modname); $filePath = $file->getPath() . COPIX_CLASSES_DIR . "kernel" . strtolower($file->fileName) . '.class.php'; //var_dump($filePath); if (is_readable($filePath)) { $modservice =& CopixClassesFactory::Create($modname . '|kernel' . $modname); if (method_exists($modservice, "create")) { $subtitle = $node_type == 'BU_ECOLE' && isset($nodeInfo['ALL']->eco_type) ? $nodeInfo['ALL']->eco_type : ''; $prenom = isset($nodeInfo['prenom']) ? $nodeInfo['prenom'] : ''; $modid = $modservice->create(array('title' => trim($prenom . ' ' . $nodeInfo['nom']), 'subtitle' => $subtitle, 'node_type' => $node_type, 'node_id' => $node_id)); if ($modid != null) { Kernel::registerModule($module->module_type, $modid, $node_type, $node_id); } } } } } } }
/** * Inclusion du fichier de la classe. * @param string $pClassID l'identifiant de la classe dont on veut inclure le fichier de définition * @return string Nom de la classe. */ public static function fileInclude($pClassId) { $file = CopixSelectorFactory::create($pClassId); if ($file->fileName == '') { return self::_dirInclude($pClassId, $file); } return self::_loadClass($pClassId, false, false, $file); }
/** * gets the name of the final DAORecord */ function getDAORecordName($DAOid) { $selector =& CopixSelectorFactory::create($DAOid); if ($selector->isValid) { return 'CompiledDAORecord' . $selector->fileName; } trigger_error(CopixI18N::get('copix:dao.error.selector.invalid', $DAOId), E_USER_ERROR); }
/** * Push the context for the template file we're using * @param $tpl the template id we wants to display. Has to be valid. */ function _pushContext($tplId) { $tpl = CopixSelectorFactory::create($tplId); if (!$tpl->isValid) { return false; } else { CopixContext::push($tpl->module); } }