public function run($args) { $criteria = new CDbCriteria(); $criteria->condition = 'ifcheck=:ifcheck'; $criteria->params = array(':ifcheck' => '已通过'); $news = Bl::model()->findAll($criteria); foreach ($news as $new) { $node = new stdClass(); $node->title = $new->title; $node->field_phone['und'][0]['value'] = $new->phone; $node->type = "_xiansuo"; $node->body['und'][0]['value'] = $new->content; $node->field_shimin['und'][0]['value'] = $new->name; $node->uid = 1; $node->language = 'zh-hans'; $node->status = 1; //(1 or 0): published or not $node->promote = 0; //(1 or 0): promoted to front page $node->comment = 2; // 0 = comments disabled, 1 = read only, 2 = read/write if ($new->img1 != "") { $suoluetu = 'e://wamp/www/epaper/assets/bl/b_' . $new->img1; $file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1); $file = file_copy($file, 'public://pictures/'); $node->field_tux['und'][0] = (array) $file; $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://wm12.cn:88/admin/assets/img/" . $new->img1 . " \" style=\"width: 100%;\"/></div>"; $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value']; } $node = node_submit($node); // Prepare node for saving node_save($node); unset($node); } }
/** * Implementation of hook_settings() for themes. */ function singular_settings($settings) { // Add js & css drupal_add_css('misc/farbtastic/farbtastic.css', 'module', 'all', FALSE); drupal_add_js('misc/farbtastic/farbtastic.js'); drupal_add_js(drupal_get_path('theme', 'singular') . '/js/settings.js'); drupal_add_css(drupal_get_path('theme', 'singular') . '/css/settings.css'); file_check_directory(file_directory_path(), FILE_CREATE_DIRECTORY, 'file_directory_path'); // Check for a new uploaded logo, and use that instead. if ($file = file_save_upload('background_file', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = 'singular_background.' . $parts['extension']; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $settings['background_path'] = $file->filepath; } } $form = array(); $form['layout'] = array('#title' => t('Layout'), '#type' => 'select', '#options' => array('fixed' => t('Fixed width'), 'fluid' => t('Fluid width')), '#default_value' => !empty($settings['layout']) ? $settings['layout'] : 'fixed'); $form['messages'] = array('#type' => 'fieldset', '#tree' => FALSE, '#title' => t('Autoclose messages'), '#descriptions' => t('Select the message types to close automatically after a few seconds.')); $form['messages']['autoclose'] = array('#type' => 'checkboxes', '#options' => array('status' => t('Status'), 'warning' => t('Warning'), 'error' => t('Error')), '#default_value' => !empty($settings['autoclose']) ? $settings['autoclose'] : array('status')); $form['style'] = array('#title' => t('Styles'), '#type' => 'select', '#options' => singular_get_styles(), '#default_value' => !empty($settings['style']) ? $settings['style'] : 'sea'); $form['custom'] = array('#tree' => FALSE, '#type' => 'fieldset', '#attributes' => array('class' => $form['style']['#default_value'] == 'custom' ? 'singular-custom-settings' : 'singular-custom-settings hidden')); $form['custom']['background_file'] = array('#type' => 'file', '#title' => t('Background image'), '#maxlength' => 40); if (!empty($settings['background_path'])) { $form['custom']['background_preview'] = array('#type' => 'markup', '#value' => !empty($settings['background_path']) ? theme('image', $settings['background_path'], NULL, NULL, array('width' => '100'), FALSE) : ''); } $form['custom']['background_path'] = array('#type' => 'value', '#value' => !empty($settings['background_path']) ? $settings['background_path'] : ''); $form['custom']['background_color'] = array('#title' => t('Background color'), '#type' => 'textfield', '#size' => '7', '#maxlength' => '7', '#default_value' => !empty($settings['background_color']) ? $settings['background_color'] : '#888888', '#suffix' => '<div id="singular-colorpicker"></div>'); $form['custom']['background_repeat'] = array('#title' => t('Tile'), '#type' => 'select', '#options' => array('no-repeat' => t('Don\'t tile'), 'repeat-x' => t('Horizontal'), 'repeat-y' => t('Vertical'), 'repeat' => t('Both')), '#default_value' => !empty($settings['background_repeat']) ? $settings['background_repeat'] : 'no-repeat'); return $form; }
/** * Implements hook_setings_submit(). */ function nuboot_radix_settings_submit($form, &$form_state) { $settings = array(); // If the user entered a path relative to the system files directory for // for the hero unit, store a public:// URI so the theme system can handle it. if (!empty($values['hero_path'])) { $values['hero_path'] = _system_theme_settings_validate_path($values['hero_path']); } // Get the previous value. $previous = $form['hero']['hero_path']['#default_value']; if ($previous !== 'profiles/dkan/themes/contrib/nuboot_radix/assets/images/hero.jpg') { $previous = 'public://' . $previous; } else { $previous = FALSE; } if ($file = file_save_upload('hero_upload')) { $parts = pathinfo($file->filename); $destination = 'public://' . $parts['basename']; $file->status = FILE_STATUS_PERMANENT; if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) { $_POST['hero_path'] = $form_state['values']['hero_path'] = $destination; // If new file has a different name than the old one, delete the old. if ($previous && $destination != $previous) { drupal_unlink($previous); } } } else { // Avoid error when the form is submitted without specifying a new image. $_POST['hero_path'] = $form_state['values']['hero_path'] = $previous; } }
/** * 原目录,复制到的目录 * */ function file_copy($from, $to, $filenamearr = array()) { $dir = opendir($from); if (!is_dir($to)) { @mkdir($to, CREATE_DIR_MODE, true); } while (false !== ($file = readdir($dir))) { if (file_exists($to . '/' . $file)) { //continue; } if ($filenamearr) { if (!in_array($file, $filenamearr)) { continue; } } if ($file != '.' && $file != '..') { if (is_dir($from . '/' . $file)) { file_copy($from . '/' . $file, $to . '/' . $file, $filenamearr); } else { copy($from . '/' . $file, $to . '/' . $file); } } } closedir($dir); }
/** * 原目录,复制到的目录 * */ function file_copy($from, $to, $filenamearr = array()) { $status = true; $dir = @opendir($from); if (!is_dir($to)) { @hg_mkdir($to); } while (false !== ($file = readdir($dir))) { if ($filenamearr) { if (!in_array($file, $filenamearr)) { continue; } } if ($file != '.' && $file != '..') { if (is_dir($from . '/' . $file)) { file_copy($from . '/' . $file, $to . '/' . $file, $filenamearr); } else { if (!@copy($from . '/' . $file, $to . '/' . $file)) { $status = false; break; } } } } closedir($dir); return $status; }
public function generateImage($object, $field, $instance, $bundle) { $object_field = array(); static $available_images = array(); if (empty($available_images)) { $available_images = $this->getImages(); } if (empty($available_images)) { $args = func_get_args(); return call_user_func_array('_image_devel_generate', $args); } $extension = array_rand(array('jpg' => 'jpg', 'png' => 'png')); $min_resolution = empty($instance['settings']['min_resolution']) ? '100x100' : $instance['settings']['min_resolution']; $max_resolution = empty($instance['settings']['max_resolution']) ? '600x600' : $instance['settings']['max_resolution']; if (FALSE === ($tmp_file = drupal_tempnam('temporary://', 'imagefield_'))) { return FALSE; } $destination = $tmp_file . '.' . $extension; file_unmanaged_move($tmp_file, $destination, FILE_EXISTS_REPLACE); $rand_file = array_rand($available_images); if (!empty($instance['settings']['file_directory'])) { $instance['settings']['file_directory'] = $instance['settings']['file_directory'] . '/'; } $destination_dir = $field['settings']['uri_scheme'] . '://' . $instance['settings']['file_directory']; file_prepare_directory($destination_dir, FILE_CREATE_DIRECTORY); if ($this->settings['devel_image_no_alter']) { $file = $available_images[$rand_file]; $file = file_copy($file, $destination_dir); } else { $image = image_load($rand_file); $min = explode('x', $min_resolution); $max = explode('x', $max_resolution); $max[0] = $max[0] < $min[0] ? $min[0] : $max[0]; $max[1] = $max[1] < $min[1] ? $min[1] : $max[1]; $width = rand((int) $min[0], (int) $max[0]); $height = rand((int) $min[1], (int) $max[1]); if (!image_scale_and_crop($image, $width, $height)) { return FALSE; } // Use destination image type. $image->info['extension'] = $extension; if (!image_save($image, $destination)) { return FALSE; } $source = new stdClass(); $source->uri = $destination; $source->uid = 1; // TODO: randomize? Use case specific. $source->filemime = $image->info['mime_type']; $source->filename = drupal_basename($image->source); $destination = $destination_dir . basename($destination); $file = file_move($source, $destination, FILE_CREATE_DIRECTORY); } $object_field['fid'] = $file->fid; $object_field['alt'] = devel_create_greeking(4); $object_field['title'] = devel_create_greeking(4); return $object_field; }
public function actionCreate() { if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time']) & isset($_POST['uid'])) { //用户积分修改 $u = user_load($_POST['uid']); $edit = array('field_jifen' => array('und' => array(0 => array('value' => $u->field_jifen['und'][0]['value'] + 3)))); user_save($u, $edit); $node->title = $_POST['title']; $node->field_phone['und'][0]['value'] = $_POST['phone']; $node->type = "sr"; $node->body['und'][0]['value'] = $_POST['content']; $node->uid = $_POST['uid']; $node->language = 'zh-hans'; $node->status = 0; //(1 or 0): published or not $node->promote = 0; //(1 or 0): promoted to front page $node->comment = 2; // 0 = comments disabled, 1 = read only, 2 = read/write //$node->field_riq['und'][0]['value'] =date('Y:m:d H:i:s'); $node->field_riq['und'][0]['value'] = $_POST['create_time']; $node->field_src['und'][0]['value'] = $_POST['place']; $node->field_status['und'][0]['value'] = '处理中'; //默认为匿名 if (isset($_POST['name'])) { $node->field_shimin['und'][0]['value'] = $_POST['name']; } $image = CUploadedFile::getInstanceByName('img'); if (is_object($image) && get_class($image) === 'CUploadedFile') { $dir = Yii::getPathOfAlias('webroot') . '/assets/urban/'; //$ext = $image->getExtensionName(); $fileName = uniqid() . '.jpg'; $name = $dir . $fileName; $image->saveAs($name, true); $file = (object) array('uid' => $_POST['uid'], 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1); $file = file_copy($file, 'public://pictures/urban'); $node->field_tux['und'][0] = (array) $file; } $node = node_submit($node); // Prepare node for saving node_save($node); $basic = new basic(); $basic->error_code = 0; //$basic->error_msg="no input parameters"; $jsonObj = CJSON::encode($basic); echo $jsonObj; } else { $basic = new basic(); $basic->error_code = 1; $basic->error_msg = "no input parameters"; $jsonObj = CJSON::encode($basic); echo $jsonObj; } }
public function run($args) { //$news=Yw::model()->findAll(); $criteria = new CDbCriteria(); // $criteria->select=array('content','create_time','nick'); // $criteria->condition='article_id=:article_id AND ifcheck=:ifcheck'; $criteria->order = 'id DESC'; //降序 最新的总是在最前面 // $criteria->params=array(':article_id'=>$param['id'],':ifcheck'=>'已通过'); $news = Zt::model()->findAll($criteria); foreach ($news as $key => $new) { if ($key < 2) { $node = new stdClass(); $node->title = $new->title; $node->body['und'][0]['value'] = $new->content; $node->field_fubiaoti['und'][0]['value'] = $new->subTitle; $node->field_src['und'][0]['value'] = $new->src; $node->field_label['und'][0]['value'] = $new->label; $node->field_myspecial['und'][0]['tid'] = 98; $node->uid = 1; $node->type = 'article'; $node->language = 'zh-hans'; $node->status = 1; //(1 or 0): published or not $node->promote = 0; //(1 or 0): promoted to front page $node->comment = 2; // 0 = comments disabled, 1 = read only, 2 = read/write if ($new->img3 != "") { $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img3 . " \" style=\"width: 100%;\"/></div>"; $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value']; } if ($new->img2 != "") { $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img2 . " \" style=\"width: 100%;\"/></div>"; $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value']; } if ($new->img1 != "") { $suoluetu = 'http://202.99.222.132:88/admin/assets/img/b_' . $new->img1; $file = (object) array('uid' => 1, 'uri' => $suoluetu, 'filemime' => 'image/jpeg', 'status' => 1); $file = file_copy($file, 'public://pictures/'); $node->field_image['und'][0] = (array) $file; $htmlimg = "<div style=\"text-align: center;\"><img src=\" http://202.99.222.132:88/admin/assets/img/" . $new->img1 . " \" style=\"width: 100%;\"/></div>"; $node->body['und'][0]['value'] = $htmlimg . $node->body['und'][0]['value']; } $node = node_submit($node); // Prepare node for saving //print_r($node); node_save($node); } } }
/** * Creates a file, then tests the tokens generated from it. */ function testFileTokenReplacement() { $node_storage = $this->container->get('entity.manager')->getStorage('node'); $token_service = \Drupal::token(); $language_interface = \Drupal::languageManager()->getCurrentLanguage(); // Create file field. $type_name = 'article'; $field_name = 'field_' . strtolower($this->randomMachineName()); $this->createFileField($field_name, 'node', $type_name); $test_file = $this->getTestFile('text'); // Coping a file to test uploads with non-latin filenames. $filename = drupal_dirname($test_file->getFileUri()) . '/текстовый файл.txt'; $test_file = file_copy($test_file, $filename); // Create a new node with the uploaded file. $nid = $this->uploadNodeFile($test_file, $field_name, $type_name); // Load the node and the file. $node_storage->resetCache(array($nid)); $node = $node_storage->load($nid); $file = file_load($node->{$field_name}->target_id); // Generate and test sanitized tokens. $tests = array(); $tests['[file:fid]'] = $file->id(); $tests['[file:name]'] = String::checkPlain($file->getFilename()); $tests['[file:path]'] = String::checkPlain($file->getFileUri()); $tests['[file:mime]'] = String::checkPlain($file->getMimeType()); $tests['[file:size]'] = format_size($file->getSize()); $tests['[file:url]'] = String::checkPlain(file_create_url($file->getFileUri())); $tests['[file:created]'] = format_date($file->getCreatedTime(), 'medium', '', NULL, $language_interface->getId()); $tests['[file:created:short]'] = format_date($file->getCreatedTime(), 'short', '', NULL, $language_interface->getId()); $tests['[file:changed]'] = format_date($file->getChangedTime(), 'medium', '', NULL, $language_interface->getId()); $tests['[file:changed:short]'] = format_date($file->getChangedTime(), 'short', '', NULL, $language_interface->getId()); $tests['[file:owner]'] = String::checkPlain(user_format_name($this->adminUser)); $tests['[file:owner:uid]'] = $file->getOwnerId(); // Test to make sure that we generated something for each token. $this->assertFalse(in_array(0, array_map('strlen', $tests)), 'No empty tokens generated.'); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId())); $this->assertEqual($output, $expected, format_string('Sanitized file token %token replaced.', array('%token' => $input))); } // Generate and test unsanitized tokens. $tests['[file:name]'] = $file->getFilename(); $tests['[file:path]'] = $file->getFileUri(); $tests['[file:mime]'] = $file->getMimeType(); $tests['[file:size]'] = format_size($file->getSize()); foreach ($tests as $input => $expected) { $output = $token_service->replace($input, array('file' => $file), array('langcode' => $language_interface->getId(), 'sanitize' => FALSE)); $this->assertEqual($output, $expected, format_string('Unsanitized file token %token replaced.', array('%token' => $input))); } }
function migrate() { global $term_dir; $completed = array(); $names = $_POST['edit']['migrate']; foreach ($names as $name => $status) { $files = file_scan_directory($term_dir, $name); if (count($files) != 1) { print count($files) . " files match the name: {$name}"; exit; } $image = array_pop($files); $image->filename_orig = $image->filename; if ($status == 1) { $image->tid = migrate_term_image_get_tid($image->name); if (!taxonomy_get_term($image->tid)) { print "cant find the tid: {$tid}"; exit; } $t_i_image = db_fetch_object(db_query('SELECT path FROM {term_image} WHERE tid = %d', $image->tid)); if ($t_i_image) { $term->has_image = true; } if ($term->has_image) { taxonomy_image_delete($image->tid); } if (file_copy($image->filename) != 1) { print "couldnt copy file: {$image->filename} to new location"; exit; } db_query("INSERT INTO {term_image} (tid, path) VALUES (%d, '%s')", $image->tid, $image->filename); $completed[] = $image; } if ($_POST['edit']['delete'][$name] == 1) { file_delete($image->filename_orig); $deleted[] = $image; } } if ($c = count($completed)) { print "Updated {$c} terms"; } else { print "No terms updated"; } if ($c = count($deleted)) { print "Deleted {$c} node_image(s)"; } else { print "No images deleted"; } }
function file_copy($src, $des, $filter) { $dir = opendir($src); @mkdir($des); while (false !== ($file = readdir($dir))) { if ($file != '.' && $file != '..') { if (is_dir($src . '/' . $file)) { file_copy($src . '/' . $file, $des . '/' . $file, $filter); } elseif (!in_array(substr($file, strrpos($file, '.') + 1), $filter)) { copy($src . '/' . $file, $des . '/' . $file); } } } closedir($dir); }
public function test_file() { $file1 = self::getDir() . '/dir1/foo.txt'; $file2 = self::getDir() . '/dir2/bar.txt'; $file3 = self::getDir() . '/dir2/baz.txt'; $file3_name = 'baz.txt'; $file4 = self::getDir() . '/dir4/yolo.txt'; $this->assertFalse(file_exists($file1)); file_create($file1); file_write($file1, ''); $this->assertTrue(file_exists($file1)); $this->assertEquals('', file_read($file1)); file_write($file1, 'foo'); $this->assertEquals('foo', file_read($file1)); file_append($file1, '_bar'); $this->assertEquals('foo_bar', file_read($file1)); file_prepend($file1, '#'); $this->assertEquals('#foo_bar', file_read($file1)); file_append($file1, '_bar'); file_prepend($file1, '#'); $this->assertEquals('##foo_bar_bar', file_read($file1)); file_append($file1 . '_append', '_bar'); $this->assertEquals(file_read($file1 . '_append'), '_bar'); file_prepend($file1 . '_prepend', '#'); $this->assertEquals(file_read($file1 . '_prepend'), '#'); $this->assertFalse(file_exists($file2)); file_copy($file1, $file2); $this->assertTrue(file_exists($file2)); $this->assertEquals(file_read($file1), file_read($file2)); $this->assertFalse(file_exists($file3)); file_rename($file2, $file3_name); $this->assertFalse(file_exists($file2)); $this->assertTrue(file_exists($file3)); $this->assertEquals(file_read($file1), file_read($file3)); $this->assertFalse(file_exists($file4)); file_move($file3, $file4); $this->assertFalse(file_exists($file3)); $this->assertTrue(file_exists($file4)); $this->assertEquals(file_read($file1), file_read($file4)); file_delete($file4); file_delete($file4); $this->assertFalse(file_exists($file4)); $this->assertEquals(self::getDir() . '/dir1', file_get_directory($file1)); $this->assertEquals('txt', file_get_extension($file1)); $this->assertEquals('foo.txt', file_get_name($file1)); }
function intranet_system_theme_settings_submit($form, &$form_state) { $settings = array(); $file = file_save_upload('footer_image_upload'); $bg_imags = array('bg_image_upload' => 'bg_image_path', 'header_image_upload' => 'header_image_path', 'footer_image_upload' => 'footer_image_path'); foreach ($bg_imags as $upload => $path) { // Check for a new uploaded file, and use that if available. if ($file = file_save_upload($upload)) { $parts = pathinfo($file->filename); $destination = 'public://' . $parts['basename']; $file->status = FILE_STATUS_PERMANENT; if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) { } $form_state['values'][$path] = $destination; } } }
function open_framework_settings_submit($form, &$form_state) { $settings = array(); // Get the previous value $previous = 'public://' . $form['background_container']['body_bg_path']['#default_value']; $file = file_save_upload('body_bg_upload'); if ($file) { $parts = pathinfo($file->filename); $destination = 'public://' . $parts['basename']; $file->status = FILE_STATUS_PERMANENT; if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) { $_POST['body_bg_path'] = $form_state['values']['body_bg_path'] = $destination; } } else { // Avoid error when the form is submitted without specifying a new image $_POST['body_bg_path'] = $form_state['values']['body_bg_path'] = $previous; } }
function add_datastream_from_file($datastream_file, $datastream_id, $datastream_label = null, $datastream_mimetype = '', $controlGroup = 'M') { module_load_include('php', 'fedora_repository', 'mimetype'); if (empty($datastream_mimetype)) { // Get mime type from the file extension. $mimetype_helper = new mimetype(); $datastream_mimetype = $mimetype_helper->getType($datastream_file); } $original_path = $datastream_file; // Temporarily move file to a web-accessible location. file_copy($datastream_file, file_directory_path()); $datastream_url = drupal_urlencode($datastream_file); $url = file_create_url($datastream_url); $return_value = $this->add_datastream_from_url($url, $datastream_id, $datastream_label, $datastream_mimetype, $controlGroup); if ($original_path != $datastream_file) { file_delete($datastream_file); } return $return_value; }
function hosting_themes_settings_submit($form, &$form_state) { // Get the previous value $previous = 'public://' . $form['contact']['contact_icon']['#default_value']; $file = file_save_upload('contact_icon_upload'); if ($file) { $parts = pathinfo($file->filename); $destination = 'public://' . $parts['basename']; $file->status = FILE_STATUS_PERMANENT; if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) { $_POST['contact_icon'] = $form_state['values']['contact_icon'] = $destination; if ($destination != $previous) { return; } } } else { // Avoid error when the form is submitted without specifying a new image $_POST['contact_icon'] = $form_state['values']['contact_icon'] = $previous; } }
public function actionCreate() { if (isset($_POST['phone']) & isset($_POST['title']) & isset($_POST['content']) & isset($_POST['place']) & isset($_POST['create_time'])) { $node->title = $_POST['title']; $node->field_phone['und'][0]['value'] = $_POST['phone']; $node->type = "sr"; $node->body['und'][0]['value'] = $_POST['content']; $node->uid = 1; $node->language = 'zh-hans'; $node->status = 0; //(1 or 0): published or not $node->promote = 0; //(1 or 0): promoted to front page $node->comment = 2; // 0 = comments disabled, 1 = read only, 2 = read/write $node->field_riq['und'][0]['value'] = date('Y:m:d H:i:s'); $node->field_src['und'][0]['value'] = $_POST['place']; $node->field_status['und'][0]['value'] = '处理中'; if (isset($_POST['name'])) { $node->field_shimin['und'][0]['value'] = $_POST['name']; } $image = CUploadedFile::getInstanceByName('img'); if (is_object($image) && get_class($image) === 'CUploadedFile') { $dir = Yii::getPathOfAlias('webroot') . '/assets/pic/'; //$ext = $image->getExtensionName(); $fileName = uniqid() . '.jpg'; $name = $dir . $fileName; $image->saveAs($name, true); $file = (object) array('uid' => 1, 'uri' => $name, 'filemime' => file_get_mimetype($filepath), 'status' => 1); $file = file_copy($file, 'public://pictures/'); $node->field_tux['und'][0] = (array) $file; } $node = node_submit($node); // Prepare node for saving node_save($node); echo '1'; } else { echo '0'; } }
function academy_settings_submit($form, &$form_state) { $settings = array(); // Get the previous value $previous = 'public://' . $form['bg_image']['bg_path']['#default_value']; $file = file_save_upload('bg_upload'); if ($file) { $parts = pathinfo($file->filename); $destination = 'public://' . $parts['basename']; $file->status = FILE_STATUS_PERMANENT; if (file_copy($file, $destination, FILE_EXISTS_REPLACE)) { $_POST['bg_path'] = $form_state['values']['bg_path'] = $destination; // If new file has a different name than the old one, delete the old if ($destination != $previous) { drupal_unlink($previous); } } } else { // Avoid error when the form is submitted without specifying a new image $_POST['bg_path'] = $form_state['values']['bg_path'] = $previous; } }
/** * Funzione che consente di creare automaticamente un contenuto drupal con le immagini jpg caricate in temp_img * e i dati exif ricavati da esse. * * @param $lat * @param $lng * @param $fileName * */ function createContentFromImage($lat, $lng, $fileName) { $node = new stdClass(); // Create a new node object Or page, or whatever content type you like $node->type = "exif_data"; // Set some default values node_object_prepare($node); $node->language = "en"; $node->uid = 1; $coords = (object) array('lat' => $lat, 'lng' => $lng); $node->field_posizione['und'][0] = (array) $coords; //@ToDo here you have to substitute the path $file_path = "/var/www/.." . $fileName; $count_photo = count($file_path); for ($i = 0; $i < $count_photo; $i++) { if (getimagesize($file_path)) { $file_gallery = (object) array('uid' => 0, 'uri' => $file_path, 'filemime' => file_get_mimetype($file_path), 'status' => 1); //substitute "your_destination_folder" with a folder name try { file_copy($file_gallery, 'public://your_destination_folder'); $node->field_image['und'][0] = (array) $file_gallery; echo "File correctly copied"; } catch (Exception $e) { echo $e->getMessage(); } } } //$node = node_submit($node); // Prepare node for saving if ($node = node_submit($node)) { // Prepare node for saving node_save($node); //Drupal node saving function call $status = "Content created correctly" . ""; } else { $status = "Something went wrong during the node submitting"; } echo $status; }
function save() { include load('include.lang'); if (!$this->is_allow()) { return $this->_($L['upload_not_allow']); } $this->set_savepath($this->savepath); $this->set_savename($this->savename); if (file_copy($this->file, DT_ROOT . '/' . $this->saveto)) { if (!@getimagesize(DT_ROOT . '/' . $this->saveto)) { file_del(DT_ROOT . '/' . $this->saveto); return $this->_($L['upload_bad']); } if ($this->maxsize > 0 && filesize(DT_ROOT . '/' . $this->saveto) > $this->maxsize) { file_del(DT_ROOT . '/' . $this->saveto); return $this->_($L['upload_size_limit'] . ' (' . intval($this->maxsize / 1024) . 'Kb)'); } $this->image = 1; return true; } else { return $this->_($L['upload_failed']); } }
$seo_title = $subtitle . $seo_delimiter . $seo_title; } $destoon_task = "moduleid={$moduleid}&html=show&itemid={$itemid}&page={$page}"; if ($EXT['wap_enable']) { $head_mobile = $EXT['wap_url'] . 'index.php?moduleid=' . $moduleid . '&itemid=' . $itemid . ($page > 1 ? '&page=' . $page : ''); } $filename = $total == 1 ? DT_ROOT . '/' . $MOD['moduledir'] . '/' . $fileurl : DT_ROOT . '/' . $MOD['moduledir'] . '/' . itemurl($item, $page); if ($total > 1) { $pages = showpages($item, $total, $page); $content = $contents[$page - 1]; } if ($MOD['keylink']) { $content = keylink($content, $moduleid); } ob_start(); include template($template, $module); $data = ob_get_contents(); ob_clean(); if ($DT['pcharset']) { $filename = convert($filename, DT_CHARSET, $DT['pcharset']); } file_put($filename, $data); if ($page == 1 && $total > 1) { $indexname = DT_ROOT . '/' . $MOD['moduledir'] . '/' . itemurl($item, 0); if ($DT['pcharset']) { $indexname = convert($indexname, DT_CHARSET, $DT['pcharset']); } file_copy($filename, $indexname); } } return true;
/** * Project Import Action * * @return void */ function action_project_import() : void { if (!($file = http_files('import'))) { message(_('No file to import')); } elseif ($file['ext'] === 'zip') { import_zip($file['tmp_name']); } elseif (in_array($file['ext'], ['html', 'odt'])) { $path = path('tmp', uniqid($file['name'], true)); file_copy($file['tmp_name'], $path . '/' . $file['name']); import_page($path . '/' . $file['name']); file_delete($path); } redirect(url('*/admin')); }
<?php defined('DT_ADMIN') or exit('Access Denied'); file_copy(DT_ROOT . '/api/ajax.php', DT_ROOT . '/' . $dir . '/ajax.php'); install_file('index', $dir, 1); install_file('list', $dir, 1); install_file('show', $dir, 1); install_file('search', $dir, 1); install_file('private', $dir, 1); install_file('view', $dir, 1);
/** * Returns a Drupal file object of the enclosed resource. * * @param string $destination * The path or uri specifying the target directory in which the file is * expected. Don't use trailing slashes unless it's a streamwrapper scheme. * @param int $replace * (optional) Replace behavior when the destination file already exists: * - FILE_EXISTS_REPLACE - Replace the existing file. If a managed file with * the destination name exists then its database entry will be updated. * If no database entry is found then a new one will be created. * - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename * is unique. * - FILE_EXISTS_ERROR - Do nothing and return FALSE. * Defaults to FILE_EXISTS_RENAME. * * @return \Drupal\file\Entity\FileInterface * A Drupal temporary file object of the enclosed resource. * * @throws \RuntimeException * If file object could not be created. * * @todo Refactor this */ public function getFile($destination, $replace = FILE_EXISTS_RENAME) { $file = FALSE; if (!$this->uri) { return $file; } // Prepare destination directory. file_prepare_directory($destination, FILE_MODIFY_PERMISSIONS | FILE_CREATE_DIRECTORY); // Copy or save file depending on whether it is remote or local. if (drupal_realpath($this->uri)) { $file = entity_create('file', ['uid' => 0, 'uri' => $this->uri, 'filemime' => $this->mimeType, 'filename' => basename($this->uri)]); if (drupal_dirname($file->getFileUri()) != $destination) { $file = file_copy($file, $destination, $replace); } else { // If file is not to be copied, check whether file already exists, // as file_save() won't do that for us (compare file_copy() and // file_save()) $existing_files = file_load_multiple([], ['uri' => $file->getFileUri()]); if ($existing_files) { return reset($existing_files); } $file->save(); } } else { $filename = drupal_basename($this->uri); if (\Drupal::moduleHandler()->moduleExists('transliteration')) { require_once drupal_get_path('module', 'transliteration') . '/transliteration.inc'; $filename = transliteration_clean_filename($filename); } if (file_uri_target($destination)) { $destination = trim($destination, '/') . '/'; } try { $file = file_save_data($this->getContent(), $destination . $filename, $replace); } catch (\Exception $e) { watchdog_exception('Feeds', $e, nl2br(SafeMarkup::checkPlain($e))); } } // We couldn't make sense of this enclosure, throw an exception. if (!$file) { throw new \RuntimeException(SafeMarkup::format('Invalid enclosure %enclosure', ['%enclosure' => $this->uri])); } return $file; }
/** * Moves a file to a new location. * - Checks if $source and $dest are valid and readable/writable. * - Performs a file move if $source is not equal to $dest. * - If file already exists in $dest either the call will error out, replace the * file or rename the file based on the $replace parameter. * * @param $source A string specifying the file location of the original file. * This parameter will contain the resulting destination filename in case of * success. * @param $dest A string containing the directory $source should be copied to. * If this value is omitted, Drupal's 'files' directory will be used. * @param $replace Replace behavior when the destination file already exists. * - FILE_EXISTS_REPLACE - Replace the existing file * - FILE_EXISTS_RENAME - Append _{incrementing number} until the filename is unique * - FILE_EXISTS_ERROR - Do nothing and return FALSE. * @return True for success, FALSE for failure. */ function file_move(&$source, $dest = 0, $replace = FILE_EXISTS_RENAME) { $path_original = is_object($source) ? $source->filepath : $source; if (file_copy($source, $dest, $replace)) { $path_current = is_object($source) ? $source->filepath : $source; if ($path_original == $path_current || file_delete($path_original)) { return 1; } drupal_set_message(t('The removal of the original file %file has failed.', array('%file' => $path_original)), 'error'); } return 0; }
continue; } } $t = filemtime($f); if ($t >= $ft && $t <= $tt) { $lists[] = $f; } } $find = count($lists); if ($find) { $dir = DT_ROOT . '/file/patch/' . timetodate($ft, 'Y-m-d H.i') . '~' . timetodate($tt, 'Y-m-d H.i') . '/'; if (is_dir($dir)) { dir_delete($dir); } foreach ($lists as $f) { file_copy($f, $dir . str_replace(DT_ROOT . '/', '', $f)); @touch($dir . str_replace(DT_ROOT . '/', '', $f), filemtime($f)); } msg('备份成功 ' . $find . ' 个文件,已保存于file/patch目录', '?file=' . $file, 5); } msg('没有符合条件的文件'); } else { $files = glob(DT_ROOT . '/*'); $dirs = $rfiles = $baks = $ups = array(); foreach ($files as $f) { $bn = basename($f); if (is_file($f)) { $rfiles[] = $bn; } else { $dirs[] = $bn; }
<?php if (c("openDlg1")->execute()) { $data = c("openDlg1")->fileName; $Len = strlen($data); if ($data[$Len - 3] . $data[$Len - 2] . $data[$Len - 1] == "kpp") { file_copy(c("openDlg1")->fileName, DOC_ROOT . "pl/" . basename(c("openDlg1")->fileName)); } dir_search("pl/", $x, ".kpp", false, false); c("listBox1")->text = $x; c("listBox1")->items->add("Export.kpp"); c("listBox1")->items->selected = "Export.kpp"; $i = c("listBox1")->itemIndex; $data = c("listBox1")->items->count - 1; if ($i > 0) { global $list; $arr = explode(_BR_, c("listBox1")->text); $v1 = $arr[$i]; $v2 = $arr[$i - $data]; $arr[$i - 1] = $v1; $arr[$i] = $v2; c("listBox1")->text = implode(_BR_, $arr); c("listBox1")->itemIndex = $i - $data; $v1 = $list[$i]; $v2 = $list[$i - $data]; $list[$i - $data] = $v1; $list[$i] = $v2; } c("listBox1")->items->selected = basename(c("openDlg1")->fileName); $data = file_get_contents(c("openDlg1")->fileName); eval($data);
/** * Take the call and properly dispatch it to the methods below. This method * assumes valid input. */ function dispatch($arguments) { if (array_key_exists('file', $arguments)) { if (array_key_exists('rename', $arguments)) { if (!file_directory_rename($arguments['filename'], $arguments['newname'], working_directory())) { http_error_exit('HTTP_CLIENT_FORBIDDEN'); } return true; } if (array_key_exists('copy', $arguments)) { if (!($newentry = file_copy($arguments['filename'], working_directory()))) { http_error_exit('HTTP_CLIENT_FORBIDDEN'); } echo json_encode($newentry); return true; } if (array_key_exists('delete', $arguments)) { if (!file_delete($arguments['filename'], working_directory())) { http_error_exit('HTTP_CLIENT_FORBIDDEN'); } return true; } } if (array_key_exists('directory', $arguments)) { if (array_key_exists('listing', $arguments)) { echo json_encode(directory_listing()); return true; } if (array_key_exists('create', $arguments)) { if (!directory_create($arguments['dirname'], working_directory())) { http_error_exit('HTTP_CLIENT_FORBIDDEN'); } return true; } if (array_key_exists('delete', $arguments)) { if (!directory_delete($arguments['dirname'], working_directory())) { http_error_exit('HTTP_CLIENT_FORBIDDEN'); } return true; } if (array_key_exists('rename', $arguments)) { if (!file_directory_rename($arguments['dirname'], $arguments['newname'], working_directory())) { http_error_exit('HTTP_CLIENT_FORBIDDEN'); } return true; } } if (array_key_exists('image', $arguments)) { } if (array_key_exists('upload', $arguments)) { store_uploaded_file($arguments['filename'], $arguments['filedata'], working_directory()); return true; } return false; }
function bootstrap_settings($saved_settings) { $defaults = array('layout_front_display_page_title' => 1, 'layout_front_display_page_content' => 1, 'layout_front_offcanvas_sidebar' => 1, 'mobile_contact_btns_icons' => 1, 'layout_staff_directory_layout' => 'grid', 'mobile_breadcrumb_btn_text' => 'Where am I?', 'mobile_offcanvas_btn_text' => 'What else is in this section?'); $settings = array_merge($defaults, $saved_settings); // Staff directory layout $staff_directory_layout = array('rows' => t('rows'), 'grid' => t('grid')); // Form processing if ($file = file_save_upload('bootstrap_touch_icon_default_upload', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = $file->filename; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $settings['bootstrap_touch_icon_default_path'] = $file->filepath; } else { dsm('Failed to upload the default touch icon.'); } } if ($file = file_save_upload('bootstrap_touch_icon_ipad_upload', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = $file->filename; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $settings['bootstrap_touch_icon_ipad_path'] = $file->filepath; } else { dsm('Failed to upload the iPad touch icon.'); } } if ($file = file_save_upload('bootstrap_touch_icon_iphone_r_upload', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = $file->filename; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $settings['bootstrap_touch_icon_iphone_r_path'] = $file->filepath; } else { dsm('Failed to upload the iPhone Retina touch icon.'); } } if ($file = file_save_upload('bootstrap_touch_icon_ipad_r_upload', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = $file->filename; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $settings['bootstrap_touch_icon_ipad_r_path'] = $file->filepath; } else { dsm('Failed to upload the iPad Retina touch icon.'); } } if ($file = file_save_upload('bootstrap_touch_icon_windows_metro_upload', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = $file->filename; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $settings['bootstrap_touch_icon_windows_metro_path'] = $file->filepath; } else { dsm('Failed to upload the iPad Retina touch icon.'); } } if ($file = file_save_upload('mobile_logo_upload', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = $file->filename; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $settings['mobile_logo_path'] = $file->filepath; } else { dsm('Failed to upload the mobile logo.'); } } // Mobile $form['mobile'] = array('#type' => 'fieldset', '#title' => t('Mobile'), '#collapsible' => TRUE, '#collapsed' => TRUE); // Mobile header $form['mobile']['mobile_nav_bg'] = array('#type' => 'textfield', '#title' => t('Override header background color'), '#size' => 6, '#description' => t('The 6 digit hexidecimal color value. Do not include hash (#).'), '#default_value' => $settings['mobile_nav_bg']); // Mobile breadcrumb button text $form['mobile']['mobile_breadcrumb_btn_text'] = array('#type' => 'textfield', '#title' => t('Breadcumb toggle text'), '#description' => t('Change the text on the breadcrumb toggle button.'), '#default_value' => $settings['mobile_breadcrumb_btn_text']); // Mobile offcanvas toggle button text $form['mobile']['mobile_offcanvas_btn_text'] = array('#type' => 'textfield', '#title' => t('Sidebar toggle text'), '#description' => t('Change the text on the sidebar toggle button.'), '#default_value' => $settings['mobile_offcanvas_btn_text']); // Custom contact action buttons $form['mobile']['mobile_contact_btns'] = array('#type' => 'fieldset', '#title' => t('Mobile contact buttons'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['mobile']['mobile_contact_btns']['mobile_contact_btns_icons'] = array('#type' => 'checkbox', '#title' => t('Display icons?'), '#default_value' => $settings['mobile_contact_btns_icons']); // Custom mobile logo $form['mobile']['mobile_logo'] = array('#type' => 'fieldset', '#title' => t('Mobile logo'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['mobile']['mobile_logo']['mobile_logo_markup'] = array('#type' => 'markup', '#value' => t('<p>Optional. Upload a logo to replace the default on small devices.</p>')); $form['mobile']['mobile_logo']['mobile_logo_use'] = array('#type' => 'checkbox', '#title' => t('Replace logo with mobile logo on small devices?'), '#default_value' => $settings['mobile_logo_use']); $form['mobile']['mobile_logo']['mobile_logo_path'] = array('#type' => 'textfield', '#title' => t('Path to logo'), '#value' => $settings['mobile_logo_path'], '#default_value' => ''); $form['mobile']['mobile_logo']['mobile_logo_upload'] = array('#type' => 'file', '#title' => t('Upload image')); // If file exists then show image if (!empty($settings['mobile_logo_path'])) { $form['mobile']['mobile_logo']['mobile_logo_preview'] = array('#type' => 'markup', '#value' => !empty($settings['mobile_logo_path']) ? theme('image', $settings['mobile_logo_path']) : ''); } /* * Form components */ // Touch icons fieldset $form['touch_icons'] = array('#type' => 'fieldset', '#title' => t('Touch icons'), '#collapsible' => TRUE, '#collapsed' => TRUE); // Default touch icon fieldset $form['touch_icons']['default_touch_icon'] = array('#type' => 'fieldset', '#title' => t('Default icon'), '#collapsible' => FALSE, '#collapsed' => FALSE); $form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_description'] = array('#type' => 'markup', '#value' => t('The default touch icon used for older Apple and Android devices.<br />Size: 57x57px.')); // Use apple touch icon $form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_use'] = array('#type' => 'checkbox', '#title' => t('Use default touch icon?'), '#default_value' => $settings['bootstrap_touch_icon_default_use']); // Default touch icon path $form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_path'] = array('#type' => 'textfield', '#title' => t('Path to touch icon'), '#value' => $settings['bootstrap_touch_icon_default_path'], '#default_value' => ''); // Default touch icon file upload $form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_upload'] = array('#type' => 'file', '#title' => t('Upload image')); // Default touch icon preview // If file exists then show image if (!empty($settings['bootstrap_touch_icon_default_path'])) { $form['touch_icons']['default_touch_icon']['bootstrap_touch_icon_default_preview'] = array('#type' => 'markup', '#value' => !empty($settings['bootstrap_touch_icon_default_path']) ? theme('image', $settings['bootstrap_touch_icon_default_path']) : ''); } // ipad touch icon fieldset $form['touch_icons']['ipad_touch_icon'] = array('#type' => 'fieldset', '#title' => t('iPad icon'), '#collapsible' => FALSE, '#collapsed' => FALSE); // Use ipad touch icon $form['touch_icons']['ipad_touch_icon']['bootstrap_touch_icon_ipad_use'] = array('#type' => 'checkbox', '#title' => t('Use iPad touch icon?'), '#default_value' => $settings['bootstrap_touch_icon_ipad_use']); // ipad icon path $form['touch_icons']['ipad_touch_icon']['bootstrap_touch_icon_ipad_path'] = array('#type' => 'textfield', '#title' => t('Path to iPad touch icon'), '#value' => $settings['bootstrap_touch_icon_ipad_path'], '#default_value' => ''); // ipad icon file upload $form['touch_icons']['ipad_touch_icon']['bootstrap_touch_icon_ipad_upload'] = array('#type' => 'file', '#title' => t('Upload image')); // ipad icon preview // If file exists then show image if (!empty($settings['bootstrap_touch_icon_ipad_path'])) { $form['touch_icons']['ipad_touch_icon']['bootstrap_apple_touch_icon_ipad_preview'] = array('#type' => 'markup', '#value' => !empty($settings['bootstrap_touch_icon_ipad_path']) ? theme('image', $settings['bootstrap_touch_icon_ipad_path']) : ''); } // iPhone Retina touch icon fieldset $form['touch_icons']['iphone_r_touch_icon'] = array('#type' => 'fieldset', '#title' => t('iPhone Retina icon'), '#collapsible' => FALSE, '#collapsed' => FALSE); // Use iPhone Retina touch icon $form['touch_icons']['iphone_r_touch_icon']['bootstrap_touch_icon_iphone_r_use'] = array('#type' => 'checkbox', '#title' => t('Use iPhone retina touch icon?'), '#default_value' => $settings['bootstrap_touch_icon_iphone_r_use']); // iPhone Retina icon path $form['touch_icons']['iphone_r_touch_icon']['bootstrap_touch_icon_iphone_r_path'] = array('#type' => 'textfield', '#title' => t('Path to iPhone Retina touch icon'), '#value' => $settings['bootstrap_touch_icon_iphone_r_path'], '#default_value' => ''); // iPhone Retina icon file upload $form['touch_icons']['iphone_r_touch_icon']['bootstrap_touch_icon_iphone_r_upload'] = array('#type' => 'file', '#title' => t('Upload image')); // iPhone Retina icon preview // If file exists then show image if (!empty($settings['bootstrap_touch_icon_iphone_r_path'])) { $form['touch_icons']['iphone_r_touch_icon']['bootstrap_apple_touch_icon_iphone_r_preview'] = array('#type' => 'markup', '#value' => !empty($settings['bootstrap_touch_icon_iphone_r_path']) ? theme('image', $settings['bootstrap_touch_icon_iphone_r_path']) : ''); } // iPad Retina touch icon fieldset $form['touch_icons']['ipad_r_touch_icon'] = array('#type' => 'fieldset', '#title' => t('iPad Retina icon'), '#collapsible' => FALSE, '#collapsed' => FALSE); // Use iPad Retina touch icon $form['touch_icons']['ipad_r_touch_icon']['bootstrap_touch_icon_ipad_r_use'] = array('#type' => 'checkbox', '#title' => t('Use iPad retina touch icon?'), '#default_value' => $settings['bootstrap_touch_icon_ipad_r_use']); // iPad Retina icon path $form['touch_icons']['ipad_r_touch_icon']['bootstrap_touch_icon_ipad_r_path'] = array('#type' => 'textfield', '#title' => t('Path to iPad Retina touch icon'), '#value' => $settings['bootstrap_touch_icon_ipad_r_path'], '#default_value' => ''); // iPad Retina icon file upload $form['touch_icons']['ipad_r_touch_icon']['bootstrap_touch_icon_ipad_r_upload'] = array('#type' => 'file', '#title' => t('Upload image')); // iPad Retina icon preview // If file exists then show image if (!empty($settings['bootstrap_touch_icon_ipad_r_path'])) { $form['touch_icons']['ipad_r_touch_icon']['bootstrap_apple_touch_icon_ipad_r_preview'] = array('#type' => 'markup', '#value' => !empty($settings['bootstrap_touch_icon_ipad_r_path']) ? theme('image', $settings['bootstrap_touch_icon_ipad_r_path']) : ''); } // Windows metro touch icon fieldset $form['touch_icons']['windows_metro_touch_icon'] = array('#type' => 'fieldset', '#title' => t('Windows metro tile'), '#collapsible' => FALSE, '#collapsed' => FALSE); // Use Windows metro touch icon $form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_use'] = array('#type' => 'checkbox', '#title' => t('Use Windows metro touch icon?'), '#default_value' => $settings['bootstrap_touch_icon_windows_metro_use']); // Use Windows metro touch color $form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_color'] = array('#type' => 'textfield', '#title' => t('Hex color value'), '#size' => 6, '#description' => t('The 6 digit hexidecimal color value. Do not include hash (#).'), '#default_value' => $settings['bootstrap_touch_icon_windows_metro_color']); // Windows metro icon path $form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_path'] = array('#type' => 'textfield', '#title' => t('Path to Windows metro icon'), '#value' => $settings['bootstrap_touch_icon_windows_metro_path'], '#default_value' => ''); // Windows metro icon file upload $form['touch_icons']['windows_metro_touch_icon']['bootstrap_touch_icon_windows_metro_upload'] = array('#type' => 'file', '#title' => t('Upload image')); // Windows metro icon preview // If file exists then show image $windows_metro_icon = '<div style="width:144px; height: 144px; padding: 20px 20px; background-color: #' . $settings['bootstrap_touch_icon_windows_metro_color'] . ';"><img src="/' . $settings['bootstrap_touch_icon_windows_metro_path'] . '"></div>'; if (!empty($settings['bootstrap_touch_icon_windows_metro_path'])) { $form['touch_icons']['windows_metro_touch_icon']['bootstrap_apple_touch_icon_windows_metro_preview'] = array('#type' => 'markup', '#value' => $windows_metro_icon); } // Layout $form['layout'] = array('#type' => 'fieldset', '#title' => t('Layout'), '#collapsible' => TRUE, '#collapsed' => TRUE); // Layout - Front $form['layout']['layout_front'] = array('#type' => 'fieldset', '#title' => t('Front'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['layout']['layout_front']['layout_front_display_page_title'] = array('#type' => 'checkbox', '#title' => t('Show page title?'), '#description' => t('Some designs dont require the page title to be visible. Uncheck if its not needed.'), '#default_value' => $settings['layout_front_display_page_title']); $form['layout']['layout_front']['layout_front_display_page_content'] = array('#type' => 'checkbox', '#title' => t('Show page content?'), '#description' => t('Some designs dont require the page content. Uncheck if its not needed.'), '#default_value' => $settings['layout_front_display_page_content']); $form['layout']['layout_front']['layout_front_offcanvas_sidebar'] = array('#type' => 'checkbox', '#title' => t('Stop off canvas sidebar?'), '#description' => t('By default, the left sidebar will hide off the screen on small devices. Check box to stop this on the front page.'), '#default_value' => $settings['layout_front_offcanvas_sidebar']); // Layout - Staff directory $form['layout']['layout_staff_directory'] = array('#type' => 'fieldset', '#title' => t('Staff directory'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['layout']['layout_staff_directory']['layout_staff_directory_layout'] = array('#type' => 'select', '#title' => t('Layout'), '#default_value' => $settings['layout_staff_directory_layout'], '#options' => $staff_directory_layout); return $form; }
public function generate_assist($dir, $sign, $theme, $id) { if (!is_dir(DATA_DIR . $sign)) { hg_mkdir(DATA_DIR . $sign); } $sign_url = DATA_DIR . $sign; if (!is_dir($sign_url . '/' . $theme)) { hg_mkdir($sign_url . '/' . $theme); } $theme_url = $sign_url . '/' . $theme; //模板路径 if (!is_dir($theme_url . '/' . $id)) { hg_mkdir($theme_url . '/' . $id); } $assist_url = $theme_url . '/' . $id; //模板路径 if (is_dir($dir . '/css')) { if (!is_dir($assist_url . '/css') || $this->updateCache) { hg_mkdir($assist_url . '/css'); file_copy($dir . 'css', $assist_url . '/css', array()); } } if (is_dir($dir . 'js')) { if (!is_dir($assist_url . '/js') || $this->updateCache) { hg_mkdir($assist_url . '/js'); file_copy($dir . 'js', $assist_url . '/js', array()); } } if (is_dir($dir . 'images')) { if (!is_dir($assist_url . '/images') || $this->updateCache) { hg_mkdir($assist_url . '/images'); } file_copy($dir . 'images', $assist_url . '/images', array()); } return true; }