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

  •  06-21-2011, 3:42 AM

    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. }  
     
View Complete Thread