problem with setting the Gallery's and template directory programmatically

Last post 06-21-2011, 7:19 AM by Emile. 3 replies.
Sort Posts: Previous Next
  •  06-18-2011, 4:44 AM 68032

    problem with setting the Gallery's and template directory programmatically

    Hello all,
     
    I'm currently busy with writing a Zend_Form_Element Component for using Cute Editor in a Zend Framework project.
    The editor works great without setting the images, media, flash, files and templates directory and points to the Uploads and Templates directory which i created in the root of my Virtual Host. But when i set the directory's programmatically i get the
    "The area you are attempting to access is forbidden" error message.
     
    I used the code you can see below to set the directory's that i want to use, hopefully someone knows how i can solve this problem.
    1. $ImageGalleryPath                       = '/Uploads/images';   
    2.         $FlashGalleryPath                       = '/Uploads/flash';   
    3.         $MediaGalleryPath                       = '/Uploads/media';   
    4.         $FilesGalleryPath                       = '/Uploads/files';   
    5.         $TemplateGalleryPath                    = '/templates';   
    6.   
    7.         $editor->ImageGalleryPath                =   $ImageGalleryPath;   
    8.         $editor->FlashGalleryPath                =   $FlashGalleryPath;   
    9.         $editor->MediaGalleryPath                =   $MediaGalleryPath;   
    10.         $editor->FilesGalleryPath                =   $FilesGalleryPath;   
    11.         $editor->TemplateGalleryPath         =   $TemplateGalleryPath;  

    Thanks in advance,
     
    Regards Emile
    Filed under:
  •  06-19-2011, 10:48 AM 68036 in reply to 68032

    Re: problem with setting the Gallery's and template directory programmatically

    Hi Emile,
     
    I set the directory path programmatically, it works fine on my end, can you clear browser cache, restart browser and try it again? 

    <?php include_once("cuteeditor_files/include_CuteEditor.php") ; ?>
    <html>
    <head>
    <title>Edit Static Html Example -- PHP Content Management, PHP WYSIWYG,
    PHP HTML Editor, PHP Text Editor</title>
    <link rel="stylesheet" href="php.css" type="text/css" />
    </head>
    <body>
    <form name="theForm" action="1.php?postback=true" method="post">
    <h1>Edit Static Html</h1>
    <br />
    </div>
    <br />
    <?php
    $editor=new CuteEditor();
    $editor->ID="Editor1";
    $editor->ImageGalleryPath                =   "/phphtmledit/uploads1";
    $editor->FlashGalleryPath                =   "/phphtmledit/uploads1";
    $editor->MediaGalleryPath                =    "/phphtmledit/uploads1";
    $editor->FilesGalleryPath                =    "/phphtmledit/uploads1";
    $editor->TemplateGalleryPath         =    "/phphtmledit/uploads1";
    //  $editor->EditorBodyStyle="font:normal 12px arial;";
    $editor->EditorWysiwygModeCss="php.css";
    $editor->EditCompleteDocument=true;
    if (@$_GET["postback"]!="true")
    {
     $editor->LoadHTML("document.html");
     $editor->Draw();
    }
    else
    {
     $editor->SaveFile("document.html");
     $editor->Draw();
    }
    $editor=null;

    //use $_POST["Editor1"]to retrieve the data
    ?> <textarea name="textbox1" rows="2" cols="20" id="textbox1"
     style="font-family: Arial; height: 250px; width: 730px;">
    <?php echo @stripslashes($_POST["Editor1"]) ;?>
                </textarea></form>
    </body>
    </html>
     
    Thanks for asking
  •  06-21-2011, 3:42 AM 68067 in reply to 68036

    Re: problem with setting the Gallery's and template directory programmatically

    Hi Eric
     
    Thank you for your answer, but unfortunatly it doesn't solve my problem.
    When i create a normal php file with your code and change the path's to the one i specified in
    my Zend_Form_Element it's working as it should be, and the strange thing is if i then reload the page
    with my Zend_Form_Element for Cute Editor it's also working great.
     
    So it seems that my Zend_Form_Element that i'm writing to use Cute Editor with
    Zend Framework doesn't set the Gallery's and template paths to the include_CuteEditor.php file or the cache.
     
    Below you can see my Zend_Form_Element source code for using Cute Editor with the Zend Framework (i used the Joomla plugin as example)
    1. <?php   
    2.   
    3. require_once 'Zend/Registry.php';   
    4. require_once 'ZendX/JQuery/View/Helper/UiWidget.php';   
    5.   
    6. class app_View_Helper_FormCuteEditor extends Zend_View_Helper_FormTextarea   
    7. {   
    8.     public function setView(Zend_View_Interface $view)   
    9.     {   
    10.         parent::setView($view);   
    11.         $this->CuteEditor = $this->view->CuteEditor();   
    12.         $this->CuteEditor->enable();   
    13.         return $this;   
    14.     }   
    15.        
    16.     function onGetContent($name, $editor)   
    17.     {   
    18.         return "document.getElementById(".$this->view->escape($name).").getHTML();";   
    19.     }   
    20.        
    21.     function onSetContent($name, $editor, $html)   
    22.     {   
    23.         return "document.getElementById(".$this->view->escape($name).").setHTML(".$html.");";   
    24.     }   
    25.        
    26.     function onSave($name, $editor)   
    27.     {   
    28.         return "document.getElementById(".$this->view->escape($name).").value=document.getElementById(".$this->view->escape($name).").getHTML();";   
    29.     }   
    30.        
    31.     public function formCuteEditor($name, $value = null, $attribs = null, $options = null)   
    32.     {   
    33.         $info = $this->_getInfo($name, $value, $attribs);   
    34.         extract($info); //name, value, attribs, options, listsep, disable   
    35.         // is it disabled?   
    36.         $disabled ='';   
    37.         if($disabled){   
    38.             //disabled   
    39.             $disabled = ' disabled = "disabled"';   
    40.         }   
    41.            
    42.         //make sure that there are 'rows' and 'cols' values   
    43.         //as required by the spec.   
    44.         if(is_numeric($attribs['rows'])){   
    45.             $rows = $attribs['rows'];   
    46.         }   
    47.         if(is_numeric($attribs['cols'])){   
    48.             $cols = $attribs['cols'];   
    49.         }   
    50.            
    51.         $value = str_replace("&lt;""<", $value);   
    52.         $value = str_replace("&gt;"">", $value);   
    53.         $value = str_replace("&amp;""&", $value);   
    54.         $value = str_replace("&nbsp;"" ", $value);   
    55.         $value = str_replace(array("&quot;","&#039;"), array("\"""'"), $value);   
    56.            
    57.         //ToDo auto set editor direction   
    58.         //if ($language->isRTL()) {   
    59.         //}    
    60.            
    61.         // Register the Cute Editor Component   
    62.         require_once 'scripts/editors/CuteEditor/include_CuteEditor.php';   
    63.            
    64.         $editor = new CuteEditor();   
    65.         $editor->ID = $this->view->escape($name);   
    66.         $editor->Width = $cols;   
    67.         $editor->Height = $rows;   
    68.         $editor->Text = $value;   
    69.         //$editor->FilesPath = ROOT_PATH . '/scripts/editors/CuteEditor';   
    70.            
    71.         if ($editor->EditorWysiwygModeCss)   
    72.         {   
    73.             // establish the database connection   
    74.             $db = Zend_Registry::get('dbconnection');   
    75.             $query = "SELECT template_name FROM site_templates";   
    76.             $template = $db->fetchAll($query);   
    77.                
    78.             $file_path = $this->HTMLPath('templates/'. $template . '/css/');   
    79.                
    80.             if (file_exists(ROOT_PATH . '/templates/' . $template . '/css/editor.css'))   
    81.             {   
    82.                 $content_css = $file_path . 'editor.css';   
    83.             }else{   
    84.                 $content_css = $file_path . 'template.css';   
    85.             }   
    86.         }   
    87.         $editor->EditorWysiwygModeCss            = $content_css;   
    88.         $editor->ThemeType                      = 'Office2007';   
    89.            
    90.         $ImageGalleryPath                       = '/Uploads/images';   
    91.         $FlashGalleryPath                       = '/Uploads/flash';   
    92.         $MediaGalleryPath                       = '/Uploads/media';   
    93.         $FilesGalleryPath                       = '/Uploads/files';   
    94.         $TemplateGalleryPath                    = '/Templates';   
    95.   
    96.         $editor->ImageGalleryPath                =   $this->HTMLPath($ImageGalleryPath);   
    97.         $editor->FlashGalleryPath                =   $this->HTMLPath($FlashGalleryPath);   
    98.         $editor->MediaGalleryPath                =   $this->HTMLPath($MediaGalleryPath);   
    99.         $editor->FilesGalleryPath                =   $this->HTMLPath($FilesGalleryPath);   
    100.         $editor->TemplateGalleryPath         =   $this->HTMLPath($TemplateGalleryPath);   
    101.            
    102.         $editor->Draw();   
    103.     }   
    104.        
    105.     function HTMLPath($input_path)   
    106.     {   
    107.         if(substr($input_path, 0, 1)!="/")   
    108.         {   
    109.             $ThisFileName = basename($_SERVER['PHP_SELF']); // get the file name   
    110.             $abspath = str_replace($ThisFileName,"",$_SERVER['PHP_SELF']);   // get the directory path   
    111.             $input_path=$abspath.$input_path;   
    112.             $input_path = str_replace('/''', $input_path );   
    113.         }   
    114.         return $input_path;   
    115.     }   
    116. }  
     
  •  06-21-2011, 7:19 AM 68073 in reply to 68067

    Re: problem with setting the Gallery's and template directory programmatically

    i found something weird about my Zend_Form_Element for Cute Editor,
     
    When i try to echo

    $editor->ImageGalleryPath = $this->HTMLPath($ImageGalleryPath);

    for example and refresh the page with the form it does display the directory path that i have set in the Zend_Form_Element on the page above the editor.
View as RSS news feed in XML