/** * Get file types * * @return array Array of objects */ public function get_types() { $a = array(array('name' => _ALL_FILES, 'value' => -1), array('name' => _DOCUMENTS, 'value' => 1), array('name' => _IMAGES, 'value' => 0), array('name' => _MEDIA, 'value' => 2), array('name' => _TEMPLATES, 'value' => 3)); return X4Utils_helper::array2obj($a, 'value', 'name'); }
/** * Return an array of CSS files by theme * * @param string $theme Theme name * @return array Array of objects */ private function get_css($theme) { // css file list $css = array(); $files = glob(PATH . 'themes/' . $theme . '/css/*'); foreach ($files as $i) { $name = str_replace(array('screen.css', '.css'), '', basename($i)); $css[] = array('v' => $name, 'o' => $name); } return X4Utils_helper::array2obj($css, 'v', 'o'); }
/** * Editor file * * @param integer $id_file File ID * @return void */ public function editor($id_file) { $this->dict->get_wordarray(array('files', 'form')); // get page $page = $this->get_page('files/editor'); $navbar = array($this->site->get_bredcrumb($page)); // content $view = new X4View_core('container_two'); // right $view->right = new X4View_core('editor'); $view->right->close = false; // left $view->content = new X4View_core('files/file_editor'); $view->content->page = $page; $mod = new File_model(); $file = $mod->get_by_id($id_file); if ($file) { // if the file exists $view->content->navbar = $navbar; $view->content->id_area = $file->id_area; $view->content->file = $file; $view->content->file_path = $mod->file_path; // switch to set where display the form $form = 'right'; $tinymce = false; $reset = _RESET; $submit = _SUBMIT; // build the form $fields = array(); // switch by type switch ($file->xtype) { case 0: // images // image size $size = file_exists($mod->file_path . 'img/' . $file->name) ? getimagesize($mod->file_path . 'img/' . $file->name) : ''; $view->content->width = $size[0]; $view->content->height = $size[1]; // editor form $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h3> Zoom 1:<span id="zoom_label">1</span></h3>'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => 1, 'name' => 'zoom'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); $fields[] = array('label' => _IMAGE_XCOORD, 'type' => 'text', 'value' => 0, 'name' => 'xcoord', 'rule' => 'numeric', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => _IMAGE_YCOORD, 'type' => 'text', 'value' => 0, 'name' => 'ycoord', 'rule' => 'numeric', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); $fields[] = array('label' => _IMAGE_WIDTH, 'type' => 'text', 'value' => $size[0], 'name' => 'width', 'rule' => 'numeric', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => _IMAGE_HEIGHT, 'type' => 'text', 'value' => $size[1], 'name' => 'height', 'rule' => 'numeric', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); $fields[] = array('label' => _IMAGE_LOCK_RATIO, 'type' => 'checkbox', 'value' => 1, 'name' => 'ratio'); $fields[] = array('label' => _IMAGE_ROTATE, 'type' => 'slider', 'value' => 0, 'name' => 'slider'); $fields[] = array('label' => null, 'type' => 'text', 'value' => 0, 'name' => 'rotate', 'extra' => 'readonly class="large acenter noborder"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="acenter" style="overflow:hidden;"><img id="imagethumb" src="' . FPATH . 'img/' . $file->name . '?t=' . time() . '" style="max-width:250px" /></div>'); $fields[] = array('label' => _IMAGE_AS_NEW, 'type' => 'checkbox', 'value' => 1, 'name' => 'asnew', 'checked' => 1); break; case 1: // generic file // template $form = 'left'; $view->right = ''; $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id'); $content = file_get_contents(APATH . 'files/filemanager/files/' . $file->name); $fields[] = array('label' => _TEMPLATE_EDIT, 'type' => 'textarea', 'value' => $content, 'name' => 'content'); break; case 2: // media files $mime = X4Files_helper::get_mime(APATH . 'files/filemanager/media/' . $file->name); $data = X4getid3_helper::analyze(APATH . 'files/filemanager/media/' . $file->name); $view->content->mime = $mime; $view->content->width = $data['video']['resolution_x']; $view->content->height = $data['video']['resolution_y']; $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h3> Filesize: ' . number_format($data['filesize'] / (1024 * 1024), 2, '.', ',') . ' MB</h3><p>' . _VIDEO_FORMAT_MSG . '</p>'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $mime, 'name' => 'old_format'); if ($mime != 'video/x-flv' && $mime != 'application/vnd.adobe.flash.movie' && $mime != 'application/x-shockwave-flash') { $fields[] = array('label' => _VIDEO_GET_IMAGE, 'type' => 'checkbox', 'value' => 1, 'name' => 'capture'); } $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div id="video_section"><h4>' . _VIDEO_EDIT . '</h4>'); $options = array(array('value' => 'video/quicktime', 'option' => 'MOV'), array('value' => 'video/mp4', 'option' => 'MP4'), array('value' => 'video/webm', 'option' => 'WEBM'), array('value' => 'video/ogg', 'option' => 'OGV mime 1'), array('value' => 'application/ogg', 'option' => 'OGV mime 2'), array('value' => 'video/x-flv', 'option' => 'FLV'), array('value' => 'video/avi', 'option' => 'AVI'), array('value' => 'application/vnd.adobe.flash.movie', 'option' => 'SWF flash-movie'), array('value' => 'application/x-shockwave-flash', 'option' => 'SWF shockwave-flash')); $fields[] = array('label' => _VIDEO_FORMAT, 'type' => 'select', 'value' => $mime, 'options' => array(X4Utils_helper::array2obj($options, 'value', 'option'), 'value', 'option'), 'name' => 'format', 'extra' => 'class="large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $data['video']['resolution_x'], 'name' => 'old_width'); $fields[] = array('label' => _IMAGE_WIDTH, 'type' => 'text', 'value' => $data['video']['resolution_x'], 'name' => 'width', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $data['video']['resolution_y'], 'name' => 'old_height'); $fields[] = array('label' => _IMAGE_HEIGHT, 'type' => 'text', 'value' => $data['video']['resolution_y'], 'name' => 'height', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); if ($mime != 'application/vnd.adobe.flash.movie' && $mime != 'application/x-shockwave-flash') { $fields[] = array('label' => _IMAGE_LOCK_RATIO, 'type' => 'checkbox', 'value' => 1, 'name' => 'ratio'); $fields[] = array('label' => _IMAGE_AS_NEW, 'type' => 'checkbox', 'value' => 1, 'name' => 'asnew', 'checked' => 1); } else { $fields[] = array('label' => null, 'type' => 'html', 'value' => '<h4>' . _VIDEO_SWF_MSG . '</h4>'); $reset = null; $submit = null; } $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div id="image_section"><h4>' . _VIDEO_GET_IMAGE . '</h4>'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '<div class="band inner-pad clearfix"><div class="one-half xs-one-whole">'); $fields[] = array('label' => _IMAGE_WIDTH, 'type' => 'text', 'value' => $data['video']['resolution_x'], 'name' => 'iwidth', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div><div class="one-half xs-one-whole">'); $fields[] = array('label' => _IMAGE_HEIGHT, 'type' => 'text', 'value' => $data['video']['resolution_y'], 'name' => 'iheight', 'rule' => 'numeric|min§1', 'extra' => 'class="aright large"'); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div></div>'); $fields[] = array('label' => _VIDEO_SEC, 'type' => 'text', 'value' => 0, 'name' => 'sec', 'rule' => 'numeric', 'extra' => 'class="large aright" readonly', 'suggestion' => _VIDEO_SEC_MSG); $fields[] = array('label' => null, 'type' => 'html', 'value' => '</div>'); break; case 3: // template $form = 'left'; $tinymce = true; $fields[] = array('label' => null, 'type' => 'hidden', 'value' => $id_file, 'name' => 'id'); $content = file_get_contents(APATH . 'files/filemanager/template/' . $file->name); $fields[] = array('label' => _TEMPLATE_EDIT, 'type' => 'textarea', 'value' => $content, 'name' => 'content'); break; } if ($form == 'right') { $view->right->title = $file->name; $view->right->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array($reset, $submit, 'buttons'), 'post', '', 'onclick="setForm(\'editor\')";', 'onclick="reset_editor()"'); } else { if ($tinymce) { // edit template $view->content->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array($reset, $submit, 'buttons'), 'post', '', 'onclick="setForm(\'editor\', \'content\')";', 'onclick="reset_editor()"'); $view->content->tinymce = new X4View_core('tinymce'); $view->content->tinymce->id_area = $file->id_area; } else { // edit generic text file $view->content->form = X4Form_helper::doform('editor', $_SERVER["REQUEST_URI"], $fields, array($reset, $submit, 'buttons'), 'post', '', 'onclick="setForm(\'editor\')";', 'onclick="reset_editor()"'); } } // if submitted if (X4Route_core::$post) { $e = X4Validation_helper::form($fields, 'editor'); if ($e) { $this->saving($id_file, $_POST); } else { $this->notice($fields); } die; } $view->render(TRUE); } else { header('Location: ' . BASE_URL . 'files'); } }