26 2014-10-30 14:31:53

Re: editPage plugin experiment

Nice wink https://github.com/nakome/Panel/blob/ma … age/gr.php

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

27 2014-10-30 16:01:43 (edited by dextra 2014-10-30 16:02:21)

Re: editPage plugin experiment

brother in line 16  gr.php be the change from

        'New Image' => 'Νέα εικόναe',

change in

        'New Image' => 'Νέα εικόνα',

28 2014-11-01 12:21:21

Re: editPage plugin experiment

Hi nakome
for me does not work on my server!
what could be wrong;
while works in localhost without any problems!

29 (edited by nakome 2014-11-01 14:37:04)

Re: editPage plugin experiment

Php version ? I have 5.3

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

30 2014-11-01 14:49:17

Re: editPage plugin experiment

nakome wrote:

Php version ? I have 5.3

my php version 5.3

31 2014-11-01 20:34:10

Re: editPage plugin experiment

I fix the problem  please update and try https://github.com/nakome/Panel

The problem was

 $_SERVER['REQUEST_URI'] 

I have changed for this 

 trim(Morfy::factory()->getUrl(), '/')

And i fix  css also.


Note: In folder images remeber create folder public/images and  cmod  755

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

32 2014-11-04 15:30:51

Re: editPage plugin experiment

yes now it works!
a quick question: how do I add two new categories;
example blog, test1, test2

33 2014-11-04 20:25:42

Re: editPage plugin experiment

I make only for pages and blog but you can add more code, the problem is  make for example new file in portfolio folder, you can edit or update but you can't make new file in new page section you need add in link like this:

http://localhost:8080/morfy/panel?updateFile=portfolio/the-name-of-file

And now you can edit or update the file.


If not understand i make a video ok.


This is a example of portfolio folder:

Go to file  plugins/panel/panel.php  and for example in  277  in empty line paste  this code


Morfy::factory()->addAction('getPortfolioPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    $folder = 'portfolio'; // This is the name of folder
    // show folder  files
    $folder_path_dir = CONTENT_PATH.'/'.$folder;
    $folder_files = Panel::File_scan($folder_path_dir);
    $html = '<h5 class="divider">Portfolio:</h5>'; // this is the title 
    foreach ($folder_files as $folder_file) {
        if(is_file($folder_path_dir.'/'.$folder_file)){
        // get blog pages    
        $folder_filename =  str_replace('.md','',$folder_file);
         $html .= '<div class="tumb-grid">
            <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$folder.'/'.$folder_filename .'" class="tumb">'.$folder_filename .'</a>
             <div class="desc"> 
                <ul>
                    <li><a class="btn btn-primary btn-sm" href="?editFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                    <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].'\')" class="btn btn-danger btn-sm" href="?deleteFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                </ul>
             </div>
          </div>';   
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});

Now go to line 144 and add this

Morfy::factory()->runAction('getPortfolioPages');


This is the complete code

<?php
/**
 *  Panel
 *
 *  @package Morfy
 *  @subpackage Plugins
 *  @author Moncho Varela / Nakome
 *  @copyright 2014 Romanenko Sergey / Awilum
 *  @version 1.0.0
 *
 */
// define root in plugin
define('ROOT',PLUGINS_PATH.'/panel/');
// debug
$debug = false;
if($debug){
    ini_set('display_errors',1);  
    error_reporting(E_ALL);
}else{
    ini_set('display_errors',0);  
    error_reporting(E_ALL);
}
// include class panel
require('library/class/class.panel.php');
// Call scripts and styles in theme header
Morfy::factory()->addAction('theme_header', function () {
    $editor_styles = '
        <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
        <link rel="stylesheet" href="'.Morfy::$config['site_url'].'/plugins/panel/assets/css/panel.css" />
        <script rel="javascript" src="'.Morfy::$config['site_url'].'/plugins/panel/assets/js/panel.js"></script>';
    // only load in panel
     if(trim(Morfy::factory()->getUrl(), '/') == 'panel') {
        echo $editor_styles;
    };
});
Morfy::factory()->addAction('theme_content_after', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    if(trim(Morfy::factory()->getUrl(), '/') == 'panel') {
        Morfy::factory()->runAction('panel');
        // use default if empty in config.php
        $password = Panel::Config(Morfy::$config['password'],'demo');      
        $secret_key1 =  Panel::Config(Morfy::$config['secret_key_1'],'secret_key1');
        $secret_key2 =  Panel::Config(Morfy::$config['secret_key_2'],'secret_key2');
        $hash = md5($secret_key1.$password.$secret_key2); 
        // get actions
        if (Panel::Request_Get('action')) {
            $action = Panel::Request_Get('action');
            // swich
            switch ($action) {
                case 'login':
                    // isset
                    if ((Panel::Request_Post('password')) && (Panel::Request_Post('token')) && (Panel::Request_Post('password') === $password)) {
                            $_SESSION['login'] = $hash;
                            Panel::Cookie_set('login',10);
                            Panel::isLogin();
                            // redirect if true
                            Panel::Notification('success','Success',$lang['Hello Admin'],Panel::Root('panel'));
                    }else{
                        Panel::Notification('error','Error',$lang['You need provide a password'],Panel::Root('panel'));
                    }
                break;
                case 'logout':
                    Panel::Cookie_delete('login');
                    Panel::isLogout();
                    Panel::redirect(Panel::Root());
                break;
            }
        }
        // Delete images function 
        Morfy::factory()->runAction('deleteImages');
    }
});
// Call plugin with  echo Morfy::factory()->runAction('files');
Morfy::factory()->addAction('files', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    // edit File ?editFile= file
    if (Panel::Request_Get('editFile')) {
        // get file 
        $file = Panel::getContent(CONTENT_PATH.'/'.$_GET['editFile'].'.md');
        $filename = Panel::Request_Get('editFile');
        require_once('library/includes/update.php');
    }else if (Panel::Request_Get('deleteFile')) {
        // get  delete file
        $file = CONTENT_PATH.'/'.Panel::Request_Get('deleteFile').'.md';
        if (!empty($file) || (!Panel::Request_Post('token'))) {
            unlink($file);
            // show Notification
            Panel::Notification('success','Success',$lang['The File'].' '.Panel::Request_Get('deleteFile').' '.$lang['has been deleted'],Panel::Root('panel'));
        }
    }else if (Panel::Request_Get('saveFile')) {
        // get content
        if(Panel::Request_Post('filename')) $filename = Panel::Request_Post('filename'); else $filename = '';
        if(Panel::Request_Post('content')) $content = Panel::Request_Post('content'); else $content = '';
        if(Panel::Request_Post('isBlog')){
            // save
            Panel::setContent(CONTENT_PATH.'/blog/'.Panel::seoLink($filename).'.md',$content);
        }else{
            // save
            Panel::setContent(CONTENT_PATH.'/'.Panel::seoLink($filename).'.md',$content);
        }
        // show Notification
        Panel::Notification('success','Success',$lang['The File'].' '.$filename.' '.$lang['has been save'],Panel::Root('panel'));
    }else if (Panel::Request_Get('updateFile')) {
        // name of file
        $filename = Panel::Request_Get('updateFile');
        // get content
        if(Panel::Request_Post('content')) $content = Panel::Request_Post('content'); else $content = '';
        // save
        Panel::setContent(CONTENT_PATH.'/'.$filename.'.md',$content);
        // show Notification
        Panel::Notification('success','Success',$lang['The File'].' '.$filename.' '.$lang['has been save'],Panel::Root('panel'));
    }else{
       Morfy::factory()->runAction('getPages');
       Morfy::factory()->runAction('getBlogPages');
       Morfy::factory()->runAction('getPortfolioPages');
    }
});
// Call plugin with  echo Morfy::factory()->runAction('getPages');
Morfy::factory()->addAction('getPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    // content folder
    $content_path_dir = CONTENT_PATH;
    // show pages
    $files = Panel::File_scan($content_path_dir);
    $html = '<h5 class="divider">'.$lang['Pages'].':</h5>';
    foreach ($files as $file) {
        if(is_file($content_path_dir.'/'.$file)){
            // get only name 
            $filename =  str_replace('.md','',$file);
            if($filename != 'panel' && $filename != 'blog'){
            $html .= '<div class="tumb-grid">
                <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$filename .'" class="tumb">'.$filename .'</a>
                 <div class="desc"> 
                    <ul>
                        <li><a class="btn btn-primary btn-sm" href="?editFile='.$filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                        <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].' \')" class="btn btn-danger btn-sm" href="?deleteFile='.$filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                    </ul>
                 </div>
              </div>';    
            }
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});
// Call plugin with  echo Morfy::factory()->runAction('getBlogPages');
Morfy::factory()->addAction('getBlogPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    $folder = 'blog'; // name of new folder here
    // show blog files
    $folder_path_dir = CONTENT_PATH.'/'.$folder;
    $folder_files = Panel::File_scan($folder_path_dir);
    $html = '<h5 class="divider">'.$lang['Blog'].':</h5>';
    foreach ($folder_files as $folder_file) {
        if(is_file($folder_path_dir.'/'.$folder_file)){
            // get blog pages    
            $folder_filename =  str_replace('.md','',$folder_file);
            // not show index
            if($folder_filename != 'index'){
             $html .= '<div class="tumb-grid">
                <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$folder.'/'.$folder_filename .'" class="tumb">'.$folder_filename .'</a>
                 <div class="desc"> 
                    <ul>
                        <li><a class="btn btn-primary btn-sm" href="?editFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                        <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].'\')" class="btn btn-danger btn-sm" href="?deleteFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                    </ul>
                 </div>
              </div>';   
            }
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});
// Call plugin with  echo Morfy::factory()->runAction('getPortfolioPages');
Morfy::factory()->addAction('getPortfolioPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    $folder = 'portfolio'; // This is the name of folder
    // show folder  files
    $folder_path_dir = CONTENT_PATH.'/'.$folder;
    $folder_files = Panel::File_scan($folder_path_dir);
    $html = '<h5 class="divider">Portfolio:</h5>'; // this is the title 
    foreach ($folder_files as $folder_file) {
        if(is_file($folder_path_dir.'/'.$folder_file)){
        // get blog pages    
        $folder_filename =  str_replace('.md','',$folder_file);
         $html .= '<div class="tumb-grid">
            <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$folder.'/'.$folder_filename .'" class="tumb">'.$folder_filename .'</a>
             <div class="desc"> 
                <ul>
                    <li><a class="btn btn-primary btn-sm" href="?editFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                    <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].'\')" class="btn btn-danger btn-sm" href="?deleteFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                </ul>
             </div>
          </div>';   
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});
// Call plugin with Morfy::factory()->runAction('deleteImages');
Morfy::factory()->addAction('deleteImages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    // delete image file
    if(Panel::Request_Get('deleteImage')){
        // Remove full an tumb image
        unlink('public/images/full/'.Panel::Request_Get('deleteImage'));
        unlink('public/images/tumb/'.Panel::Request_Get('deleteImage'));
        // show Notification
        Panel::Notification('success','Success',$lang['The File'].' '.Panel::Request_Get('deleteImage').' '.$lang['has been deleted'],Panel::Root('panel?get=images'));
    }
});
// Call plugin with  echo Morfy::factory()->runAction('add');
Morfy::factory()->addAction('add', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require_once('library/add.php');
});
// Call plugin with  echo Morfy::factory()->runAction('auth');
Morfy::factory()->addAction('auth', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require('library/login.php');
});
// Call plugin with  echo Morfy::factory()->runAction('panel');
Morfy::factory()->addAction('panel', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require('library/panel.php');
});
// Call plugin with  echo Morfy::factory()->runAction('content');
Morfy::factory()->addAction('content', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require('library/content.php');
});
?>
..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

34 2014-11-04 20:29:32

Re: editPage plugin experiment

I make only for pages and blog but you can add more code, the problem is  make for example new file in portfolio folder, you can edit or update but you can't make new file in new page section you need add in link like this:

http://localhost:8080/morfy/panel?updateFile=portfolio/the-name-of-file

And now you can edit or update the file.


If not understand i make a video ok.


This is a example of portfolio folder:

Go to file  plugins/panel/panel.php  and for example in  277  in empty line paste  this code


Morfy::factory()->addAction('getPortfolioPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    $folder = 'portfolio'; // This is the name of folder
    // show folder  files
    $folder_path_dir = CONTENT_PATH.'/'.$folder;
    $folder_files = Panel::File_scan($folder_path_dir);
    $html = '<h5 class="divider">Portfolio:</h5>'; // this is the title 
    foreach ($folder_files as $folder_file) {
        if(is_file($folder_path_dir.'/'.$folder_file)){
        // get blog pages    
        $folder_filename =  str_replace('.md','',$folder_file);
         $html .= '<div class="tumb-grid">
            <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$folder.'/'.$folder_filename .'" class="tumb">'.$folder_filename .'</a>
             <div class="desc"> 
                <ul>
                    <li><a class="btn btn-primary btn-sm" href="?editFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                    <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].'\')" class="btn btn-danger btn-sm" href="?deleteFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                </ul>
             </div>
          </div>';   
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});

Now go to line 144 and add this

Morfy::factory()->runAction('getPortfolioPages');


This is the complete code

<?php
/**
 *  Panel
 *
 *  @package Morfy
 *  @subpackage Plugins
 *  @author Moncho Varela / Nakome
 *  @copyright 2014 Romanenko Sergey / Awilum
 *  @version 1.0.0
 *
 */
// define root in plugin
define('ROOT',PLUGINS_PATH.'/panel/');
// debug
$debug = false;
if($debug){
    ini_set('display_errors',1);  
    error_reporting(E_ALL);
}else{
    ini_set('display_errors',0);  
    error_reporting(E_ALL);
}
// include class panel
require('library/class/class.panel.php');
// Call scripts and styles in theme header
Morfy::factory()->addAction('theme_header', function () {
    $editor_styles = '
        <link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"/>
        <link rel="stylesheet" href="'.Morfy::$config['site_url'].'/plugins/panel/assets/css/panel.css" />
        <script rel="javascript" src="'.Morfy::$config['site_url'].'/plugins/panel/assets/js/panel.js"></script>';
    // only load in panel
     if(trim(Morfy::factory()->getUrl(), '/') == 'panel') {
        echo $editor_styles;
    };
});
Morfy::factory()->addAction('theme_content_after', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    if(trim(Morfy::factory()->getUrl(), '/') == 'panel') {
        Morfy::factory()->runAction('panel');
        // use default if empty in config.php
        $password = Panel::Config(Morfy::$config['password'],'demo');      
        $secret_key1 =  Panel::Config(Morfy::$config['secret_key_1'],'secret_key1');
        $secret_key2 =  Panel::Config(Morfy::$config['secret_key_2'],'secret_key2');
        $hash = md5($secret_key1.$password.$secret_key2); 
        // get actions
        if (Panel::Request_Get('action')) {
            $action = Panel::Request_Get('action');
            // swich
            switch ($action) {
                case 'login':
                    // isset
                    if ((Panel::Request_Post('password')) && (Panel::Request_Post('token')) && (Panel::Request_Post('password') === $password)) {
                            $_SESSION['login'] = $hash;
                            Panel::Cookie_set('login',10);
                            Panel::isLogin();
                            // redirect if true
                            Panel::Notification('success','Success',$lang['Hello Admin'],Panel::Root('panel'));
                    }else{
                        Panel::Notification('error','Error',$lang['You need provide a password'],Panel::Root('panel'));
                    }
                break;
                case 'logout':
                    Panel::Cookie_delete('login');
                    Panel::isLogout();
                    Panel::redirect(Panel::Root());
                break;
            }
        }
        // Delete images function 
        Morfy::factory()->runAction('deleteImages');
    }
});
// Call plugin with  echo Morfy::factory()->runAction('files');
Morfy::factory()->addAction('files', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    // edit File ?editFile= file
    if (Panel::Request_Get('editFile')) {
        // get file 
        $file = Panel::getContent(CONTENT_PATH.'/'.$_GET['editFile'].'.md');
        $filename = Panel::Request_Get('editFile');
        require_once('library/includes/update.php');
    }else if (Panel::Request_Get('deleteFile')) {
        // get  delete file
        $file = CONTENT_PATH.'/'.Panel::Request_Get('deleteFile').'.md';
        if (!empty($file) || (!Panel::Request_Post('token'))) {
            unlink($file);
            // show Notification
            Panel::Notification('success','Success',$lang['The File'].' '.Panel::Request_Get('deleteFile').' '.$lang['has been deleted'],Panel::Root('panel'));
        }
    }else if (Panel::Request_Get('saveFile')) {
        // get content
        if(Panel::Request_Post('filename')) $filename = Panel::Request_Post('filename'); else $filename = '';
        if(Panel::Request_Post('content')) $content = Panel::Request_Post('content'); else $content = '';
        if(Panel::Request_Post('isBlog')){
            // save
            Panel::setContent(CONTENT_PATH.'/blog/'.Panel::seoLink($filename).'.md',$content);
        }else{
            // save
            Panel::setContent(CONTENT_PATH.'/'.Panel::seoLink($filename).'.md',$content);
        }
        // show Notification
        Panel::Notification('success','Success',$lang['The File'].' '.$filename.' '.$lang['has been save'],Panel::Root('panel'));
    }else if (Panel::Request_Get('updateFile')) {
        // name of file
        $filename = Panel::Request_Get('updateFile');
        // get content
        if(Panel::Request_Post('content')) $content = Panel::Request_Post('content'); else $content = '';
        // save
        Panel::setContent(CONTENT_PATH.'/'.$filename.'.md',$content);
        // show Notification
        Panel::Notification('success','Success',$lang['The File'].' '.$filename.' '.$lang['has been save'],Panel::Root('panel'));
    }else{
       Morfy::factory()->runAction('getPages');
       Morfy::factory()->runAction('getBlogPages');
       Morfy::factory()->runAction('getPortfolioPages');
    }
});
// Call plugin with  echo Morfy::factory()->runAction('getPages');
Morfy::factory()->addAction('getPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    // content folder
    $content_path_dir = CONTENT_PATH;
    // show pages
    $files = Panel::File_scan($content_path_dir);
    $html = '<h5 class="divider">'.$lang['Pages'].':</h5>';
    foreach ($files as $file) {
        if(is_file($content_path_dir.'/'.$file)){
            // get only name 
            $filename =  str_replace('.md','',$file);
            if($filename != 'panel' && $filename != 'blog'){
            $html .= '<div class="tumb-grid">
                <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$filename .'" class="tumb">'.$filename .'</a>
                 <div class="desc"> 
                    <ul>
                        <li><a class="btn btn-primary btn-sm" href="?editFile='.$filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                        <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].' \')" class="btn btn-danger btn-sm" href="?deleteFile='.$filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                    </ul>
                 </div>
              </div>';    
            }
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});
// Call plugin with  echo Morfy::factory()->runAction('getBlogPages');
Morfy::factory()->addAction('getBlogPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    $folder = 'blog'; // name of new folder here
    // show blog files
    $folder_path_dir = CONTENT_PATH.'/'.$folder;
    $folder_files = Panel::File_scan($folder_path_dir);
    $html = '<h5 class="divider">'.$lang['Blog'].':</h5>';
    foreach ($folder_files as $folder_file) {
        if(is_file($folder_path_dir.'/'.$folder_file)){
            // get blog pages    
            $folder_filename =  str_replace('.md','',$folder_file);
            // not show index
            if($folder_filename != 'index'){
             $html .= '<div class="tumb-grid">
                <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$folder.'/'.$folder_filename .'" class="tumb">'.$folder_filename .'</a>
                 <div class="desc"> 
                    <ul>
                        <li><a class="btn btn-primary btn-sm" href="?editFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                        <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].'\')" class="btn btn-danger btn-sm" href="?deleteFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                    </ul>
                 </div>
              </div>';   
            }
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});
// Call plugin with  echo Morfy::factory()->runAction('getPortfolioPages');
Morfy::factory()->addAction('getPortfolioPages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    $folder = 'portfolio'; // This is the name of folder
    // show folder  files
    $folder_path_dir = CONTENT_PATH.'/'.$folder;
    $folder_files = Panel::File_scan($folder_path_dir);
    $html = '<h5 class="divider">Portfolio:</h5>'; // this is the title 
    foreach ($folder_files as $folder_file) {
        if(is_file($folder_path_dir.'/'.$folder_file)){
        // get blog pages    
        $folder_filename =  str_replace('.md','',$folder_file);
         $html .= '<div class="tumb-grid">
            <a target="_blank" href="'.Morfy::$config['site_url'].'/'.$folder.'/'.$folder_filename .'" class="tumb">'.$folder_filename .'</a>
             <div class="desc"> 
                <ul>
                    <li><a class="btn btn-primary btn-sm" href="?editFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-edit"></i>   '.$lang['Edit'].'</a></li>
                    <li><a onclick="return confirmDelete(\' '.$lang['Are you sure'].'\')" class="btn btn-danger btn-sm" href="?deleteFile='.$folder.'/'.$folder_filename .'"><i class="fa fa-trash-o"></i>   '.$lang['Delete'].'</a></li>
                </ul>
             </div>
          </div>';   
        }
    }
    $html .= '<div class="clearfix"></div>';
    echo $html;
});
// Call plugin with Morfy::factory()->runAction('deleteImages');
Morfy::factory()->addAction('deleteImages', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    // delete image file
    if(Panel::Request_Get('deleteImage')){
        // Remove full an tumb image
        unlink('public/images/full/'.Panel::Request_Get('deleteImage'));
        unlink('public/images/tumb/'.Panel::Request_Get('deleteImage'));
        // show Notification
        Panel::Notification('success','Success',$lang['The File'].' '.Panel::Request_Get('deleteImage').' '.$lang['has been deleted'],Panel::Root('panel?get=images'));
    }
});
// Call plugin with  echo Morfy::factory()->runAction('add');
Morfy::factory()->addAction('add', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require_once('library/add.php');
});
// Call plugin with  echo Morfy::factory()->runAction('auth');
Morfy::factory()->addAction('auth', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require('library/login.php');
});
// Call plugin with  echo Morfy::factory()->runAction('panel');
Morfy::factory()->addAction('panel', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require('library/panel.php');
});
// Call plugin with  echo Morfy::factory()->runAction('content');
Morfy::factory()->addAction('content', function () {
    // require language
    require('library/language/'.Panel::Config(Morfy::$config['Panel_lang'],'es').'.php');
    require('library/content.php');
});
?>
..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

35 (edited by dextra 2014-11-04 20:41:28)

Re: editPage plugin experiment

plugins/panel/library/includes/add.php

<div class="form-group">
        <label class="checkbox-inline">
          <input name="isBlog" type="checkbox"> <?php echo $lang['Check this if is a blog'];?>
        </label>
        <label class="checkbox-inline">
          <input name="isPorfolio" type="checkbox"> <?php echo $lang['Check this if is a porfolio'];?>
        </label>
    </div>

Re: editPage plugin experiment

I think something is not right
how to save a porfolio?

Re: editPage plugin experiment

Yes  but you need more code and if need other folder this is the problem

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: editPage plugin experiment

nakome wrote:

Yes  but you need more code and if need other folder this is the problem

can you tell me what more code;

Re: editPage plugin experiment

Ok go to plugins/panel/panel.php and update the code like this ( in line 122 ).

Before:

        if(Panel::Request_Post('filename')) $filename = Panel::Request_Post('filename'); else $filename = '';
        if(Panel::Request_Post('content')) $content = Panel::Request_Post('content'); else $content = '';
        if(Panel::Request_Post('isBlog')){
            // save
            Panel::setContent(CONTENT_PATH.'/blog/'.Panel::seoLink($filename).'.md',$content);
        }else{
            // save
            Panel::setContent(CONTENT_PATH.'/'.Panel::seoLink($filename).'.md',$content);
        }

After:

        if(Panel::Request_Post('filename')) $filename = Panel::Request_Post('filename'); else $filename = '';
        if(Panel::Request_Post('content')) $content = Panel::Request_Post('content'); else $content = '';
        if(Panel::Request_Post('isBlog')){
            // save
            Panel::setContent(CONTENT_PATH.'/blog/'.Panel::seoLink($filename).'.md',$content);
          // --------------------- Start new code
        // For Form name isPortfolio
        }else if(Panel::Request_Post('isPortfolio')){
            $folder = 'portfolio'; // folder name 
            // save in folder portfolio
            Panel::setContent(CONTENT_PATH.'/'.$folder.'/'.Panel::seoLink($filename).'.md',$content);
         // --------------------- End of new code
        }else{
            // save
            Panel::setContent(CONTENT_PATH.'/'.Panel::seoLink($filename).'.md',$content);
        }

If you checked blog and porfolio this save only in blog.


Go to plugins/panel/includes/add.php and clone checkbox with name  isPortfolio like this:

        <!-- checkbox blog -->
    <div class="form-group">
        <label class="checkbox-inline">
          <input name="isBlog" type="checkbox"> <?php echo $lang['Check this if is a blog'];?>
      </label>
    </div>
        <!-- checkbox portfolio -->
    <div class="form-group">
        <label class="checkbox-inline">
          <input name="isPortfolio" type="checkbox"> Check this if is a Portfolio
      </label>
    </div>
..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

40 (edited by dextra 2014-11-05 10:59:20)

Re: editPage plugin experiment

There are some errors in the code

panel.php bad success
look video here smile https://dl.dropboxusercontent.com/u/834 … uccess.mp4

plugins/panel/library/panel.php line 7

      <div class="logo">
          <a href="<?php echo Panel::Root('panel'); ?>">
        <img src="<?php echo Panel::Root(); ?>plugins/panel/assets/img/logo.jpg" alt="Mofry Panel">
      </a>
    </div>

change in

      <div class="panel_logo">
          <a href="<?php echo Panel::Root('panel'); ?>">
        <img src="<?php echo Panel::Root(); ?>plugins/panel/assets/img/logo.jpg" alt="Mofry Panel">
      </a>
    </div>

Re: editPage plugin experiment

tnx nakome!!!!
I try to look at the code to learn wink

42 2014-11-05 11:40:07

Re: editPage plugin experiment

Yes i update code in gitHub but not show  sad

Take this  with option select for select folders in new page.
Plugin

Preview mp4

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: editPage plugin experiment

good
look here https://github.com/nakome/Panel/pulls

44 (edited by nakome 2014-11-05 12:37:21)

Re: editPage plugin experiment

Update Github  Demo

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: editPage plugin experiment

password change from panel settings

plugins\panel\library\includes\settings.php

<?php
if (isset($_POST['password_submit'])) {
        $post_password = isset($_POST['password']) ? $_POST['password'] : '';
        file_put_contents('config.php', "<?php
    return array(
        'site_url' => 'http://localhost/morfy',
        'site_charset' => 'UTF-8',
        'site_timezone' => 'Kwajalein',
        'site_theme' => 'default',
        'site_title' => 'demo',
        'site_description' => '',
        'site_keywords' => '',
        'email' => 'test@gmail.com',
        'Panel_lang' => 'en', // language  see library/language
        'password' => '{$post_password}',
        'secret_key_1' => '12sdf3321a321asdfas', // secret key for md5
        'secret_key_2' => '4561dsf232gdfd1asdf3', // secret key for md5
        'Panel_Images' => 'full', // name of full image folder
        'Panel_Thumbnails' => 'tumb', // name of tumb images
        'plugins' => array(
            'markdown',
            'sitemap',
            'panel'
        ),
    );
          ");
}
?>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="col-md-12">
            <form role="form" method="post">
              <div class="form-group">
                <label for="password">Password</label>
                <input type="password" name="password" class="form-control" id="password" placeholder="Enter New Password" required>
              </div>
              <input type="submit" name="password_submit" class="btn btn-primary" value="Change Password">
            </form>
        </div>    
    </div>
</div>

Video here

my problem is that I want to change only the password only
how to accomplish this;

Re: editPage plugin experiment

I think make a unique config file for admin panel

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: editPage plugin experiment

Xm...
we can do something about it;

48 2014-11-11 11:42:49

Re: editPage plugin experiment

This is the idea:


panel/library/config.json

{
    "Panel_lang": "en",
    "Password": "demo",
    "Secret_key_1": "12sdf3321a321asdfas",
    "Secret_key_2": "4561dsf232gdfd1asdf3",
    "Panel_Images": "full",
    "Panel_Thumbnails": "tumb"
}

panel/library/includes/settings.php file

<?php
    $config = Panel::getContent('../../../../../../topic/526/editpage-plugin-experiment/page/2/plugins/panel/library/forum_subdomain/config.js');
    $result = json_decode($config,true);
    if(Panel::Request_post('save_config')){
        $result = array(
            "Panel_lang" => Panel::Request_post('Panel_lang'),
            "Password" => Panel::Request_post('Password'),
            "Secret_key_1" => Panel::Request_post('Secret_key_1'),
            "Secret_key_2" => Panel::Request_post('Secret_key_2'),
            "Panel_Images" => Panel::Request_post('Panel_Images'),
            "Panel_Thumbnails" => Panel::Request_post('Panel_Thumbnails')
        );
        Panel::setContent('../../../../../../topic/526/editpage-plugin-experiment/page/2/plugins/panel/library/forum_subdomain/config.js',json_encode($result));
        Panel::Notification('success','Success','Save config file',Panel::Root('panel?get=settings'));
    }
?>
<div class="container-fluid">
    <div class="row-fluid">
        <form class="form" method="post">
            <div class="form-group">
                <label for="panel_lang">Language</label>
                <input type="text" name="Panel_lang" class="form-control" value="<?php echo $result['Panel_lang']; ?>">            
            </div>
            <div class="form-group">
                <label for="password">Password</label>
                <input type="password" name="Password" class="form-control" value="<?php echo $result['Password']; ?>">            
            </div>
            <div class="form-group">
                <label for="Secret_key_1">Secret key 1</label>
                <input type="password" name="Secret_key_1" class="form-control" value="<?php echo $result['Secret_key_1']; ?>">            
            </div>
            <div class="form-group">
                <label for="Secret_key_2">Secret key 2</label>
                <input type="password" name="Secret_key_2" class="form-control" value="<?php echo $result['Secret_key_2']; ?>">            
            </div>
            <div class="form-group">
                <label for="Panel_Images">Full Images</label>
                <input type="text" name="Panel_Images" class="form-control" value="<?php echo $result['Panel_Images']; ?>">            
            </div>
            <div class="form-group">
                <label for="Panel_Thumbnails">Thumbnail Images</label>
                <input type="text" name="Panel_Thumbnails" class="form-control" value="<?php echo $result['Panel_Thumbnails']; ?>">            
            </div>
            <div class="form-group">
                <input type="submit" name="save_config" class="btn btn-primary" value="Save Config">
            </div>
        </form>
    </div>
</div>
..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website

Re: editPage plugin experiment

bro something is wrong!
I put password 123456 and I have access to the panel
password demo while I normally access
look video https://www.dropbox.com/s/rkh6ujs2difj6 … 5.MP4?dl=0

50 2014-11-11 12:10:57

Re: editPage plugin experiment

This is only a idea i need change all config data first, you can try this link

..::: Moncho Varela ::::..   ..::: @Nakome ::::..   ..::: Github ::::..

nakome's Website