Ejemplo n.º 1
0
 function create_plugin_folders($plugin)
 {
     if (!is_object($plugin) || empty($plugin->key) || !isset($plugin->options_array['strings']) || empty($plugin->front_strings_array)) {
         return false;
     }
     $valid_folder = false;
     $missing_folders = array();
     $admin_path = $plugin->options_array['strings'];
     foreach ($this->languages as $id => $value) {
         $path = DIR_FS_PLUGINS . tep_trail_path($plugin->key) . tep_trail_path($admin_path) . $value['language_path'];
         if (!is_dir($path)) {
             $missing_folders[] = $path;
         } elseif (empty($valid_folder)) {
             $valid_folder = $path;
         }
     }
     if (empty($valid_folder) && !empty($missing_folders)) {
         return false;
     }
     for ($i = 0, $j = count($missing_folders); $i < $j; $i++) {
         tep_copy_dir($valid_folder, $missing_folders[$i]);
     }
     $fs_plugins = tep_front_physical_path(DIR_WS_CATALOG_STRINGS);
     foreach ($this->languages as $id => $value) {
         $path = $fs_plugins . tep_trail_path($value['language_path']) . $plugin->key;
         tep_mkdir($path);
     }
     return true;
 }
Ejemplo n.º 2
0
 function generate_string_folders()
 {
     extract(tep_load('languages', 'database', 'message_stack'));
     $result = true;
     if (empty($this->front_strings_array) && !isset($this->options_array['strings'])) {
         return $result;
     }
     $result = false;
     $present_folders = array();
     $missing_folders = array();
     foreach ($lng->languages as $id => $params) {
         $check_path = $this->admin_path . tep_trail_path($this->options_array['strings']) . $params['language_path'];
         if (!is_dir($check_path)) {
             $missing_folders[] = $check_path;
         } else {
             $file_path = tep_trail_path($check_path, true);
             for ($i = 0, $j = count($this->front_strings_array); $i < $j; $i++) {
                 $file = $file_path . $this->front_strings_array[$i];
                 if (is_file($file)) {
                     $present_folders[] = $check_path;
                     break;
                 }
             }
         }
     }
     if (empty($present_folders)) {
         $msg->add_session(sprintf(ERROR_PLUGIN_MISSING_STRINGS, $db->prepare_input($this->title)));
         return $result;
     }
     if (!empty($missing_folders)) {
         $present = $present_folders[0];
         for ($i = 0, $j = count($missing_folders); $i < $j; $i++) {
             tep_copy_dir($present, $missing_folders[$i]);
         }
         $msg->add_session(sprintf(WARNING_PLUGIN_MISSING_STRINGS, $db->prepare_input($this->title)), 'warning');
     }
     $result = true;
     return $result;
 }
Ejemplo n.º 3
0
function tep_copy_dir($src, $dst)
{
    extract(tep_load('message_stack'));
    //closedir(opendir($src));
    //closedir(opendir($dst));
    $src = rtrim($src, '/');
    $dst = rtrim($dst, '/');
    if (empty($src) || empty($dst) || !is_dir($src)) {
        return;
    }
    $result = tep_mkdir($dst);
    if (!$result) {
        $msg->add_session(sprintf(ERROR_CREATE_DIR, $dst));
        return;
    }
    $sub_array = glob($src . '/*');
    if (empty($sub_array)) {
        return;
    }
    foreach ($sub_array as $sub) {
        $entry = basename($sub);
        if (is_file($sub)) {
            $contents = '';
            if (!tep_read_contents($src . '/' . $entry, $contents)) {
                $msg->add_session(sprintf(ERROR_INVALID_FILE, $src . '/' . $entry));
                continue;
            }
            if (!tep_write_contents($dst . '/' . $entry, $contents)) {
                $msg->add_session(sprintf(ERROR_WRITING_FILE, $src . '/' . $entry));
                continue;
            }
        } else {
            tep_copy_dir($src . '/' . $entry, $dst . '/' . $entry);
        }
    }
    closedir(opendir($src));
    closedir(opendir($dst));
}