예제 #1
0
function se_on_save_page($strSourceText, &$oPage)
{
    seChangeLocale();
    //the lib to include
    $oCurrentFile = new PFile(__FILE__);
    require_once $oCurrentFile->getParentPath() . SLASH . 'include' . SLASH . 'lib.searchengine.php';
    if (!se_get_config('ACTIVATE', $bActivate)) {
        return $strSourceText;
    }
    if (!$bActivate) {
        return $strSourceText;
    }
    $returnval = true;
    if (!connectBdd()) {
        return false;
    }
    if (exist_page_search($oPage->getUrl())) {
        $type = 'update';
    } else {
        $type = 'insert';
    }
    switch ($type) {
        case 'insert':
            $returnval = insert_info_search($oPage, $strSourceText);
            break;
        case 'update':
            $returnval = update_info_search($oPage, $strSourceText);
            break;
    }
    closeBdd();
    return $returnval ? $strSourceText : false;
}
 function __construct()
 {
     parent::__construct();
     Usuario::checkLogin();
     // cria o formulario
     $this->form = new TQuickForm('form_Produtos');
     $this->form->class = 'tform';
     // class css do framework
     // titulo do formulario
     $this->form->setFormTitle('Produtos');
     // banco de dados em uso
     parent::setDatabase('sample');
     // model em uso
     parent::setActiveRecord('Produtos');
     // cria os campos do formulario
     $id = new THidden('id');
     $nome = new TEntry('nome');
     //eleciona a categoria
     $categoria = new TDBCombo('categoria_id', 'sample', 'Categoria', 'id', 'nome', 'nome');
     $descricao = new THtmlEditor('descricao');
     $preco = new TEntry('preco');
     $imagem = new PFile('imagem');
     $imagem->setFolder('uploads');
     $preco->addValidation('preco', new TNumericValidator());
     // somente numeros
     $preco->setNumericMask(2, '.', '');
     // seta a mascara para o mesmo padrao do mysql
     // adiciona os campos label,campo,tamanho
     $this->form->addQuickField('', $id, 100);
     $this->form->addQuickField('nome', $nome, 200);
     $this->form->addQuickField('preco', $preco, 200);
     $this->form->addQuickField('categoria', $categoria, 200);
     $this->form->addQuickField('imagem', $imagem, 200);
     $this->form->addQuickField('descricao', $descricao, 200);
     // para alterar o tamanho de componentes em sua altura e largura
     //deve coloca-las apos adicionar o campos no form
     $descricao->setSize(400, 300);
     // adciona actions no form
     $this->form->addQuickAction(_t('Save'), new TAction(array($this, 'onSave')), 'ico_save.png');
     $this->form->addQuickAction(_t('New'), new TAction(array($this, 'onEdit')), 'ico_new.png');
     // adciona o form na pagina
     parent::add($this->form);
 }
예제 #3
0
/**
 * Function sortpages
 * This fonction is call by the sortfile javascript plugins.
 * It renames the files. The file begin with a number are ordered.
 * 
 * If an object file not begin with a number, it is not ordered. 
 * 
 * @return: true if suceed, else return false.
 */
function sortpages()
{
    if (!isset($_REQUEST['filename'])) {
        return setError('Internal error in sortfiles, filename not defined');
    }
    $tabFilesNew = $_REQUEST['filename'];
    //if less than two files no need to sort
    if (sizeof($tabFilesNew) < 2) {
        return true;
    }
    //get the dir to order, take the second element because in some cas the first element is ../
    $pTemp = new PFile(SITE_PATH . urljsdecode($tabFilesNew[1]));
    $oDirToOrder = new PDir($pTemp->getParentPath());
    $i = 0;
    foreach ($tabFilesNew as $strFile) {
        $strFile = urljsdecode($strFile);
        //if not parent file
        if (SITE_PATH . $strFile != $oDirToOrder->getParentPath()) {
            //get the file number, if number exist reorder it
            //this is the original file number, if modified twice it change in php but not in html
            $oFileTest = new PFile($oDirToOrder->path . SLASH . basename($strFile));
            if ($oFileTest->is_page() || $oFileTest->is_dircategory() || $oFileTest->is_link()) {
                $oFile = getFileObject($oFileTest->path);
                $iCurrOrder = $oFile->getMenuOrder();
                $i++;
                if ($iCurrOrder != $i) {
                    //print('reorder '.$oFile->getName().' from '.$iCurrOrder.' to '.$i);
                    if (!$oFile->setMenuOrder($i)) {
                        return false;
                    }
                }
                //if file order has changed
            }
            //end if filenumber is set
        }
        //end if ofile not parent dir
    }
    //end foreach
    return true;
}
예제 #4
0
        function __getEditorFormItem($strParam, $strValue, $idForm)
        {
            $strType = $this->getParamDescr($strParam, "TYPE", "text");
            $bEditable = $this->getParamDescr($strParam, "EDITABLE", "true") == "false" ? false : true;
            $strEditable = $bEditable ? "" : " style=\"display:none;\" ";
            $strReturn = '<div class="params"' . $strEditable . ' >' . "\n";
            $strReturn .= '<label class="param" >' . _($this->getVarPrintName($strParam)) . ':</label>';
            switch ($strType) {
                case 'boolean':
                    $strChecked = $strValue == "true" ? 'checked' : '';
                    $strTpl = '<input class="paramvalue" {STYLE} type="checkbox" name="{PARAM_NAME}" id="field_{PARAM_NAME}" value="{PARAM_VALUE}" {CHECKED} onClick="javascript:if(this.checked){this.value=true;}else{this.value=false;} reloadFileConfigTextArea(\'{ID_FORM}\'); "/><br />
				<div class="reset"></div>
				';
                    $strReturn .= str_replace(array('{CHECKED}', '{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strChecked, $strEditable, $strParam, $strValue, $idForm), $strTpl);
                    break;
                case 'list':
                    $strTpl = '<select name="{PARAM_NAME}" class="paramvalue" {STYLE} id="field_{PARAM_NAME}" onChange="reloadFileConfigTextArea(\'{ID_FORM}\');">
				 {LIST_ITEMS}
				 </select>
				 <br /><div class="reset"></div>
				';
                    $strList = '';
                    $strListTpl = '	<option value="{PARAM_VALUE}" {SELECTED}>{PARAM_NAME}</option>
				';
                    $tabValues = explode(",", $this->getParamDescr($strParam, "LIST_VALUES", $strValue));
                    foreach ($tabValues as $val) {
                        $strListVal = '';
                        $strListParam = '';
                        if (preg_match('/=>/', $val)) {
                            $tabPV = explode('=>', $val);
                            $strListVal = $tabPV[1];
                            $strListParam = $tabPV[0];
                            if ($strListParam == 'list_files') {
                                //first search in theme dir then in medias path
                                $strDirPath = is_dir($strListVal) ? $strListVal : SITE_PATH . THEME_DIR . $strListVal;
                                $strDirPath = is_dir($strDirPath) ? $strDirPath : MEDIAS_PATH . SLASH . $strListVal;
                                if (is_dir($strDirPath)) {
                                    $pDirList = new PDir($strDirPath);
                                    $tabListFiles = $pDirList->listDir($pDirList->ONLY_FILES, false);
                                    foreach ($tabListFiles as $strFile) {
                                        $oFile = new PFile($strFile);
                                        $strSelected = $strFile == $strValue ? 'SELECTED' : '';
                                        $strList .= str_replace(array('{SELECTED}', '{PARAM_NAME}', '{PARAM_VALUE}'), array($strSelected, $oFile->getNameWithoutExt(), $strFile), $strListTpl);
                                    }
                                }
                            } else {
                                $strSelected = $strListVal == $strValue ? 'SELECTED' : '';
                                $strList .= str_replace(array('{SELECTED}', '{PARAM_NAME}', '{PARAM_VALUE}'), array($strSelected, $strListParam, $strListVal), $strListTpl);
                            }
                        } else {
                            $strListParam = $val;
                            $strListVal = $val;
                            $strSelected = $strListVal == $strValue ? 'SELECTED' : '';
                            $strList .= str_replace(array('{SELECTED}', '{PARAM_NAME}', '{PARAM_VALUE}'), array($strSelected, $strListParam, $strListVal), $strListTpl);
                        }
                    }
                    $strReturn .= str_replace(array('{LIST_ITEMS}', '{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strList, $strEditable, $strParam, $strValue, $idForm), $strTpl);
                    break;
                case 'password':
                    $strTpl = '<input class="paramvalueText paramvalue" {STYLE} onChange="reloadFileConfigTextArea(\'{ID_FORM}\');" type="password" name="{PARAM_NAME}" id="field_{PARAM_NAME}" value="{PARAM_VALUE}" /><br />
				<div class="reset"></div>
				';
                    $strReturn .= str_replace(array('{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strEditable, $strParam, $strValue, $idForm), $strTpl);
                    break;
                case 'textarea':
                    $strTpl = '<textarea name="{PARAM_NAME}" id="field_{PARAM_NAME}" class="paramvalue paramvalueTextArea" wrap="off"   onChange="reloadFileConfigTextArea(\'{ID_FORM}\');" >{PARAM_VALUE}</textarea>
			<br /><div class="reset"></div>
			';
                    $strReturn .= str_replace(array('{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strEditable, $strParam, $strValue, $idForm), $strTpl);
                    break;
                case 'text':
                    $strTpl = '<input class="paramvalueText paramvalue" {STYLE} onChange="reloadFileConfigTextArea(\'{ID_FORM}\');" type="text" name="{PARAM_NAME}" id="field_{PARAM_NAME}" value="{PARAM_VALUE}" /><br />
			<div class="reset"></div>
			';
                    $strReturn .= str_replace(array('{STYLE}', '{PARAM_NAME}', '{PARAM_VALUE}', '{ID_FORM}'), array($strEditable, $strParam, $strValue, $idForm), $strTpl);
                    break;
            }
            //end switch
            return $strReturn . "\n</div>\n";
        }
예제 #5
0
 function PTextFile($strPath)
 {
     parent::PFile($strPath);
 }
예제 #6
0
 function Delete()
 {
     if (!$this->_deleteCache()) {
         return false;
     }
     return parent::Delete();
 }
예제 #7
0
 /**
  * Rename the page.
  * This function is called to rename the page.
  * If the new name of the page contains specific caracters as éà, it is replace by ea,
  * but the menu name is set with special caracters
  * An event is attached to this fonction: renamepage
  * This event is used for example by the search engine plugin to index the file content.
  * 
  * The difference between move and rename, is that in move do not set the menu title !!
  * @param string $newname, the new name (basename)
  * @param string $destDir, if == false the parent dir
  * @return true if suceed
  */
 function Rename($newname, $destDir = false)
 {
     $fileNewName = $this->getUnixName($newname);
     $pageNewName = $newname;
     $pageCurrName = $this->getVirtualName();
     $fileCurrName = $this->getName();
     if (strlen($fileNewName) == 0) {
         return setError(_('Can not rename with empty name'));
     }
     //manage extensions
     $oFile = new PFile($fileNewName);
     if ($oFile->getExtension() == '') {
         $fileNewName .= '.' . $this->getExtension();
     } else {
         $oFile = new PFile($pageNewName);
         $pageNewName = $oFile->getNameWithoutExt();
     }
     if ($fileNewName == $fileCurrName && $pageCurrName == $pageNewName && $destDir === false) {
         return true;
     }
     //check the name is valid, not a php file or a cgi one for example
     if (!$this->checkname($pageNewName)) {
         return false;
     }
     //set the menu name in the ini file if has been renamed !! not moved
     if (!$destDir && !$this->setVirtualName($pageNewName)) {
         return false;
     }
     if ($fileCurrName != $fileNewName || $destDir !== false) {
         //if history dir exists, rename it
         $oDirHistoryCache = new PDir(CACHE_HIST_DIR . SLASH . $this->getId());
         if (is_dir($oDirHistoryCache->path)) {
             $destDirModify = !$destDir ? $this->getParentPath() : $destDir;
             if (substr($destDirModify, -1) == SLASH) {
                 $destDirModify = substr($destDirModify, 0, strlen($destDirModify) - 1);
             }
             $oPageNewHistory = new PPage($destDirModify . SLASH . $fileNewName);
             $strNewHistoryName = $oPageNewHistory->getId();
             if ($this->getId() != $strNewHistoryName) {
                 if (!$oDirHistoryCache->Rename($strNewHistoryName)) {
                     return false;
                 }
             }
         }
         if (!doEventAction('renamepage', array(&$this, ($destDir ? $destDir : $this->getParentPath()) . SLASH . $fileNewName))) {
             return false;
         }
         //on supprime le cache du menu
         if (!deleteMenuCache()) {
             return false;
         }
         //rename the config file if exists
         if (is_file($this->oPConfigFile->path)) {
             $oFileTmp = new PFile($fileNewName);
             if (!$this->oPConfigFile->Rename($oFileTmp->getNameWithoutExt() . ".ini", $destDir)) {
                 return false;
             }
         }
         if (!parent::Rename($fileNewName, $destDir)) {
             return false;
         }
     }
     return true;
 }
예제 #8
0
<?php

include '../../../core/config.inc.php';
require_once SITE_PATH . '/core/lib/pfile.php';
require_once SITE_PATH . '/core/lib/ppage.php';
require SITE_PATH . '/core/lib/localization.php';
//the config file
$oCurrentFile = new PFile(__FILE__);
require_once $oCurrentFile->getParentPath() . SLASH . 'lib.searchengine.php';
if (!synchroBase()) {
    printError();
} else {
    echo 'All rights !!';
}
예제 #9
0
 function Copy($newname, $parent_path = false)
 {
     if (!$this->checkName($newname)) {
         return false;
     }
     //check extension
     $oFile = new PFile($newname);
     $newname .= $oFile->getExtension() == '' ? '.' . $this->getExtension() : '';
     //check parent path access
     if (!$parent_path) {
         $parent_path = $this->getParentPath();
     }
     if (!is_writable($parent_path)) {
         return setError(_("can not copy. Directory not writable.\n Check file permissions."));
     }
     $newfile = $parent_path . SLASH . $newname;
     if (is_file($newfile) || is_dir($newfile)) {
         return setError(_("File exists") . ": " . $newname);
     }
     if (!copy($this->path, $newfile)) {
         return setError(_("Error occured while copying file") . ". " . _("Check file permissions") . ".");
     }
     return true;
 }
예제 #10
0
 function Rename($newname, $destDir = false)
 {
     $fileNewName = $this->getUnixName($newname);
     $pageNewName = $newname;
     $pageCurrName = $this->getVirtualName();
     $fileCurrName = $this->getName();
     if (strlen($fileNewName) == 0) {
         return setError(_("Can not rename with empty name"));
     }
     if ($fileNewName == $fileCurrName && $pageCurrName == $fileCurrName && $destDir === false) {
         return false;
     }
     //set the menu name in the ini file if needed
     if (!$destDir && !$this->setVirtualName($pageNewName)) {
         return false;
     }
     //if the directory has changed (move in an other one, or rename)
     if ($fileCurrName != $fileNewName || $destDir !== false) {
         //Change the virtual name
         if (!$destDir && !$this->oPConfigFile->setParam('VIRTUAL_NAME', $pageNewName)) {
             return false;
         }
         if (!$this->oPConfigFile->Save()) {
             return false;
         }
         //rename the config file if exists
         if (is_file($this->oPConfigFile->path)) {
             $oFileTmp = new PFile($fileNewName);
             if (!$this->oPConfigFile->Rename($oFileTmp->getNameWithoutExt() . ".ini", $destDir)) {
                 return false;
             }
         }
         //delete the menu cache
         if (!deleteMenuCache()) {
             return false;
         }
         if (!parent::Rename($fileNewName, $destDir)) {
             return false;
         }
     }
     return true;
 }
예제 #11
0
 /**
  * 写LOG的函数
  *
  * @param string $module 日志类型
  * @param string $file 文件名
  * @param string $lineNum 行
  * @param string $value1
  * @param string $value2
  * @param string $func 函数名
  */
 private static function m_sLog($module, $file, $lineNum, $value1, $value2 = '', $func = 'MAIN')
 {
     /*
             if (! empty($GLOBALS['G_NO_LOG'])) // 不记录Log,主要是针对loader.php
             {
                 return;
             }
     
             $ConfLevel = strtolower($GLOBALS['LOG']['LOGLEVEL']);
             if (($ConfLevel == 'w') && ($module == 'd'))
             {
                 return;
             }
             elseif (($ConfLevel == 'e') && (($module == 'd') || ($module == 'w')))
             {
                 return;
             }
     */
     $logFile = self::m_GetLogFileName($file, $module);
     $logDir = dirname($logFile);
     if (!is_dir($logDir)) {
         self::m_MakeDirs($logDir);
     }
     //$logMemo = date("Y-m-d H:i:s") . "\t[$func][LN:$lineNum]\t[PID:" . getmypid() . "][" .round(memory_get_usage() / 1024 / 1024, 2) . "M]\t";
     $logMemo = self::m_getLogMemo($file, $lineNum, $value1, $value2, $func);
     PFile::Append($logFile, $logMemo . "\n");
 }
예제 #12
0
 /**
  * This function is called each time a file is created or renamed
  * 
  * @param $strName, the name to check, or if = false, check the object file name
  * @return true if name is ok
  */
 function checkName($strName = false)
 {
     if (!$strName) {
         $strName = basename($this->path);
     }
     $oFile = new PFile($strName);
     if (!preg_match('/^[a-zA-Z0-9\\.\\s_-]*$/', $oFile->getNameWithoutExt())) {
         return setError(_('Special chars are not allowed.'));
     }
     if (strlen($oFile->getNameWithoutExt()) == 0) {
         return setError(_('Empty name is not allowed'));
     }
     return $this->checkExtension($strName);
 }
예제 #13
0
 function deleteMenuCache()
 {
     //on supprime le cache du menu
     if (is_file(SMARTY_CACHE_DIR . 'menu.cache')) {
         $menuFile = new PFile(SMARTY_CACHE_DIR . 'menu.cache');
         if (!$menuFile->Delete()) {
             return false;
         }
     }
     return true;
 }