/** * tplfct_news_rss * This is the template function rss_page use by the get feed template rss_page * * @param array $params, parameters from the template * @param Pollen CMS object $smarty * @return the feed in xml */ function tplfct_news_rss($params, &$smarty) { $strTplChannel = '<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"> <channel> <title>%CHANNEL_TITLE%</title> <link>%CHANNEL_LINK%</link> <description>%CHANNEL_DESCRIPTION%</description> <pubDate>%CHANNEL_PUBDATE%</pubDate> <generator>%CHANNEL_GENERATOR%</generator> %ITEMS% </channel> </rss> '; $strServerUrl = strstr(SITE_URL, 'http') ? '' : 'http://' . $_SERVER['SERVER_NAME'] . ''; $tabInfosChannel = array('title' => 'test', 'link' => $strServerUrl . SITE_URL, 'description' => 'ceci est la description', 'pubDate' => gmdate('D, d M Y H:i:s', time()) . ' GMT', 'generator' => 'POLLEN CMS'); $keys = array_keys($tabInfosChannel); $tabKeysTransform = array(); $tabKeysValues = array(); foreach ($keys as $aKey) { $tabKeysTransform[] = '%CHANNEL_' . strtoupper($aKey) . '%'; $tabKeysValues[] = $tabInfosChannel[$aKey]; } $strReturn = str_replace($tabKeysTransform, $tabKeysValues, $strTplChannel); $strItemTpl = ' <item> <title>%ITEM_TITLE%</title> <link>' . $strServerUrl . '%ITEM_LINK%</link> <pubDate>%ITEM_PUBDATE%</pubDate> <description>%ITEM_DESCRIPTION%</description> </item> '; $strListItems = ''; $tabItems = array(); $pdirNews =& getFileObject(PAGES_PATH . SLASH . 'actualites'); if (!$pdirNews || !is_dir($pdirNews->path)) { setError('Error can not find the new directory'); printFatalHtmlError(); } $tabNews = $pdirNews->listDir($pdirNews->ONLY_FILES); foreach ($tabNews as $strNews) { $oNews =& getFileObject($strNews); $tabItems[] = array('%ITEM_TITLE%' => $oNews->getMenuName(), '%ITEM_LINK%' => $oNews->getUrl(), '%ITEM_PUBDATE%' => gmdate('D, d M Y H:i:s', filemtime($oNews->path)) . ' GMT', '%ITEM_DESCRIPTION%' => _getNewsContent($oNews, $strServerUrl)); } foreach ($tabItems as $aItem) { $keys = array_keys($aItem); $values = array_values($aItem); $strListItems .= str_replace($keys, $values, $strItemTpl); } $strReturn = str_replace('%ITEMS%', $strListItems, $strReturn); return $strReturn; }
function _loadAllEvents() { if (is_dir(PLUGINS_DIR)) { $oPdir = getFileObject(PLUGINS_DIR); //parse each plugin directory $listDir = $oPdir->listDir($oPdir->ONLY_DIR); foreach ($listDir as $strPluginPath) { $oDirPlugin = new PPluginDir($strPluginPath); if ($oDirPlugin->isActivated()) { $listFiles = $oDirPlugin->listDir($oDirPlugin->ONLY_FILES, $bFullPath = false); //parse each files and add it in the tab events foreach ($listFiles as $strFileName) { if (preg_match('/(.+)filter\\.(.+)\\.php/', $strFileName, $tabInfo)) { $this->_events['smarty'][$tabInfo[1]][] = array('FILEPATH' => $oDirPlugin->path . SLASH . $strFileName, 'NAME' => $tabInfo[2], 'EVENT' => $tabInfo[1]); } else { if (preg_match('/insert\\.(.+)\\.php/', $strFileName, $tabInfo)) { $this->_events['smarty']['insert'][] = array('FILEPATH' => $oDirPlugin->path . SLASH . $strFileName, 'NAME' => $tabInfo[1], 'EVENT' => 'insert'); } else { if (preg_match('/function\\.(.+)\\.php/', $strFileName, $tabInfo)) { $this->_events['smarty']['function'][] = array('FILEPATH' => $oDirPlugin->path . SLASH . $strFileName, 'NAME' => $tabInfo[1], 'EVENT' => 'function'); } else { if (preg_match('/(.+)event\\.(.+)\\.php/', $strFileName, $tabInfo)) { $strEvent = $tabInfo[1]; $strName = $tabInfo[2]; $strFunction = 'pollen_' . $strEvent . 'event_' . $strName; require_once $oDirPlugin->path . SLASH . $strFileName; $this->_addEvent($strEvent, $strFunction, $pritority = 10); } else { if (preg_match('/\\.php$/', $strFileName)) { require_once $oDirPlugin->path . SLASH . $strFileName; } } } } } } } //end if plugin is activated } } }
function googleparsedir($oDir) { $strReturn = ''; $tabList = $oDir->listDir(); foreach ($tabList as $strPath) { $oTemp =& getFileObject($strPath); if ($oTemp->isPublished() && strpos($oTemp->getName(), '404') === FALSE) { if (is_dir($oTemp->path)) { $strReturn .= googleparsedir($oTemp); } else { $frequency = $oTemp->isCached() ? 'monthly' : 'always'; $strReturn .= '<url> <loc>' . $oTemp->getUrl() . '</loc> <lastmod>' . date('Y-m-d', filemtime($oTemp->path)) . '</lastmod> <changefreq>' . $frequency . '</changefreq> </url> '; } } } return $strReturn; }
function getpagemodelslist() { $oDirModels = new PDirCategory(PAGES_MODELS_PATH); if (!is_dir($oDirModels->path)) { return true; } $tabModels = $oDirModels->listDir($oDirModels->ONLY_FILES, $fullpath = true, '.htm(l)?'); $strList = ''; foreach ($tabModels as $aModelPath) { $oPageModel =& getFileObject($aModelPath); $strId = str_replace(SLASH, '/', $oPageModel->getRelativePath()); $strList .= $oPageModel->Display(70, $url = '#' . $oPageModel->getName()); } echo $strList; return true; }
function syncDir(&$pDir) { $tabList = $pDir->listDir(); foreach ($tabList as $strPath) { if (is_dir($strPath)) { if (!syncDir(getFileObject($strPath))) { return false; } } else { if (!insert_info_search(getFileObject($strPath))) { return false; } } } return true; }
<?php } ?> </ul> </div> <?php // parrent Dir, only print if not on root directory if ($current_dir != SITE_PATH && $current_dir != $rootpath && $current_dir) { $pdirParent = $pcurrent_dir->getParent(); echo $pdirParent->Display(70, '../', $url = false, $proot_dir); } //On affice les fichiers $listDir = $pcurrent_dir->listDir(); foreach ($listDir as $file) { if (is_dir($file)) { if ($obj =& getFileObject($file)) { echo $obj->Display(70, $print = false, $url = false, $proot_dir); } } else { if ($obj =& getFileObject($file)) { echo $obj->Display(70, $url = false, $proot_dir); } } } ?> <div class="reset"></div> </div><!--end div browser --> <?php include "admin_bottom.php";
/** * Return an array with this elem strut (NAME=>,URL=>) * * @return */ function getTabGuidage() { $tabReturn = array(); $strPath = $this->path; while (PAGES_PATH != $strPath) { $o =& getFileObject($strPath); if (!preg_match('/index/', $o->getName())) { $tabReturn[] = array('NAME' => $o->getMenuName(), 'URL' => $o->getUrl()); } $strPath = $o->getParentPath(); } return array_reverse($tabReturn); }
'; $strTableAvailable = '<h2>' . _('Available Plugins list') . '</h2> <table id="listPluginsAvailables" class="listPlugins"> <tr> <th>' . _('Name') . '</th> <th>' . _('Author') . '</th> <th>' . _('Version') . '</th> <th>' . _('Action') . '</th> </tr> {LIST} </table> '; $strListActivated = ''; $strListAvailable = ''; if (is_dir(PLUGINS_DIR)) { $oPdir = getFileObject(PLUGINS_DIR); //parse each plugin directory $listDir = $oPdir->listDir($oPdir->ONLY_DIR); foreach ($listDir as $strPluginPath) { $oDirPlugin = new PPluginDir($strPluginPath); $bActivated = false; $configFile->getParam($oDirPlugin->getIdName(), $bActivated, 'PLUGINS'); $strAction = $bActivated === "true" ? _('UnActivate') : _('Activate'); $strLine = '<tr> <td>' . $oDirPlugin->getPluginName() . '</td> <td>' . $oDirPlugin->getAuthor() . '</td> <td>' . $oDirPlugin->getVersion() . '</td> <td><a href="#" onClick="return toggleactivatePlugin(\'' . urljsencode($oDirPlugin->getName()) . '\',\'false\');">[ ' . $strAction . ' ]</a></td> </tr>'; if ($bActivated === "true") { $strListActivated .= $strLine;
function getFileObjectAndFind($strPath, $filter = 'findtype') { if (file_exists($strPath)) { return getFileObject($strPath); } //cut the file number $objFile = new PFile($strPath); $objParentDir = new PDir($objFile->getParentPath()); switch ($filter) { case 'file': $filter = $objParentDir->ONLY_FILES; break; case 'dir': $filter = $objParentDir->ONLY_DIR; break; case 'all': $filter = $objParentDir->ALL; break; case 'findtype': $filter = preg_match('/\\.[a-z]+$/i', $strPath) ? $objParentDir->ONLY_FILES : $objParentDir->ONLY_DIR; break; case false: $filter = $objParentDir->ONLY_FILES; break; default: $filter = $objParentDir->ONLY_FILES; break; } $strSimplePath = basename($strPath); if (!($tabFile = $objParentDir->listDir($filter, true, $strSimplePath . ($filter == $objParentDir->ONLY_DIR ? '$' : '')))) { return false; } foreach ($tabFile as $strPathFileFiltered) { $strFileName = basename($strPathFileFiltered); if ($strFileName == $strSimplePath) { return getFileObject($strPathFileFiltered); } } return setError(sprintf(_("Fatal Error, can not find the file %s"), $strSimplePath)); }
function createLink($strLinkName = false) { if (!$strLinkName) { $strLinkName = _('link ') . $this->getMenuName() . '.lnk'; } $oDirParent = getFileObject($this->getParentPath()); if (!$oDirParent->createFile($strLinkName)) { return false; } if (!($oLink = getFileObjectAndFind($oDirParent->path . SLASH . $oDirParent->getUnixName($strLinkName)))) { return setError('Internale Error. Can not find the created link file'); } if (!$oLink->setLinkedPage($this)) { return false; } return true; }
printFatalError(); } } } //url back $pdirparent =& getFileObject($pfile->getParentPath()); if (isConnected()) { echo ' <div id="path"> <div id="imgHome"></div> '; $strPath = $pfile->path; $oRoot = new PDir(strstr($pfile->path, PAGES_PATH) !== false ? PAGES_PATH : (strpos($pfile->path, PAGES_MODELS_PATH) !== false ? PAGES_MODELS_PATH : SITE_PATH)); $tabGuid = array(); while ($oRoot->path != $strPath && strlen($strPath) > 1) { $o =& getFileObject($strPath); if (is_dir($o->path)) { $fileMangementUrl = 'admin_file_management.php?rootpath=' . rawurlencode(str_replace(SITE_PATH, '', PAGES_PATH)) . '¤t_dir=' . rawurlencode($o->getRelativePath(PAGES_PATH)); $tabGuid[] = array('NAME' => $o->getName(), 'URL' => $fileMangementUrl); } $strPath = $o->getParentPath(); } $tabGuid[] = array('NAME' => str_replace('languages', _('Site Pages'), $oRoot->getName()), 'URL' => 'admin_file_management.php?rootpath=' . rawurlencode(str_replace(SITE_PATH, '', $oRoot->path))); $tabGuid = array_reverse($tabGuid); foreach ($tabGuid as $strUrlGuid) { echo '<a href="' . $strUrlGuid['URL'] . '">' . $strUrlGuid['NAME'] . '</a> > '; } echo $pfile->getShortName(); echo ' </div>'; echo $pfile->DisplayEditor();
/** * Function: getFirstPage * return the first page of the current web site * * * param: $dirSearch, the directory where to search, if not set, search in the PAGES_PATH * return: false if not found, the first page */ function getFirstPage($dirSearch = false, $adminMode = false) { $dirSearch = $dirSearch == false ? PAGES_PATH : $dirSearch; if (!is_dir($dirSearch)) { return false; } $oDirParent =& getFileObjectAndFind($dirSearch, 'dir'); if (!$oDirParent) { return false; } if (!($adminMode || $oDirParent->isPublished())) { return false; } //Try to find the index file, if found and is publised, return $file =& getFileObjectAndFind($dirSearch . SLASH . "index.html"); if ($file !== false && ($adminMode || $file->isPublished())) { return $file; } else { $file =& getFileObjectAndFind($dirSearch . SLASH . "index.php"); if ($file !== false && ($adminMode || $file->isPublished())) { return $file; } } $tab = $oDirParent->listDir($oDirParent->ALL, $fullpath = true); if (sizeof($tab) == 0) { return false; } foreach ($tab as $file) { //bug d'une image placée à l'index du site if (!(is_file($file) && !preg_match('/\\.htm[l]?$/', $file))) { $oFile =& getFileObject($file); if ($adminMode !== false || $oFile->isPublished()) { if (is_file($oFile->path)) { return $oFile; } else { $oFind =& $this->getFirstPage($oFile->path, $adminMode); if ($oFind && $oFind->isPublished()) { return $oFind; } } } } } return setError(__('No page found in the directory') . ': ' . $dirSearch); }
/** * @return PDir object the parent directory */ function getParentDir() { return getFileObject($this->getParentPath()); }
function getLinkPath($rootpath = false) { $oDir = new PDir($this->path); $root = $rootpath != false ? $rootpath : SITE_PATH . SITE . PAGES; $tabPath = explode(SLASH, $oDir->getRelativePath($root)); $pdirroot = new PDir($rootpath); $rootpath = $pdirroot->getRelativePath(); $parent = ''; $isize = sizeof($tabPath); for ($i = 0; $i < $isize; $i++) { $path = $tabPath[$i]; if ($path != '') { $parent .= $path; $obj = getFileObject($root . SLASH . $parent); echo " > <a href=\"" . $_SERVER["PHP_SELF"] . "?current_dir=" . urlencode($parent) . ($rootpath == false ? "" : "&rootpath=" . $rootpath) . "\" >" . $obj->getPrintedName(); echo "</a>"; $parent .= SLASH; } } }
*/ // parrent Dir, only print if not on root directory if ($current_dir != SITE_PATH && $current_dir != $rootpath && $current_dir) { $pdirParent = $pcurrent_dir->getParent(); echo $pdirParent->Display(100, "../", $url = false, $proot_dir); } //Faire la liste des répertoires $listDir = $pcurrent_dir->listDir($pcurrent_dir->ONLY_DIR, true); foreach ($listDir as $dir) { $objDir =& getFileObject($dir); echo $objDir->Display(70, $print = false, $url = false, $proot_dir); } /* files list */ $listFiles = $pcurrent_dir->listDir($pcurrent_dir->ONLY_FILES, true, ".*", "\\.ini\$"); foreach ($listFiles as $file) { $objFile =& getFileObject($file); $strRelativeUrl = $objFile->getRelativePath($proot_dir->path); if (SLASH != '/') { $strRelativeUrl = str_replace(SLASH, '/', $strRelativeUrl); } $url = '"javascript:setUrlFileChoice(\'' . $strRelativeUrl . '\')"'; //if(eregi(TEXTEDIT_WYSWYG."|\.php",$file)){$url="\"javascript:setUrl('".urlencode(ereg_replace("[0-9]*_","",substr($objFile->getRelativePath(),strlen($rootpath)+1)))."')\"";} echo $objFile->Display(70, $url, $proot_dir); } ?> </div> <form onSubmit="javascript: return setUrl(this.elements['real_path_selected'].value);" id="form_select_path" > <input type="text" id="path_selected" value="<?php echo preg_replace('/[0-9]*_/', '', $pcurrent_dir->getRelativePath($rootpath));