function index() { $path = \GCore\C::get('GCORE_ADMIN_PATH') . 'extensions' . DS . 'chronoforms' . DS; $files = \GCore\Libs\Folder::getFiles($path, true); $strings = array(); //function to prepare strings $prepare = function ($str) { /*$path = \GCore\C::get('GCORE_FRONT_PATH'); if(strpos($str, $path) !== false AND strpos($str, $path) == 0){ return '//'.str_replace($path, '', $str); }*/ $val = !empty(\GCore\Libs\Lang::$translations[$str]) ? \GCore\Libs\Lang::$translations[$str] : ''; return 'const ' . trim($str) . ' = "' . str_replace("\n", '\\n', $val) . '";'; }; foreach ($files as $file) { if (substr($file, -4, 4) == '.php') { // AND strpos($file, DS.'extensions'.DS) === TRUE){ //$strings[] = $file; $file_code = file_get_contents($file); preg_match_all('/l_\\(("|\')([^(\\))]*?)("|\')\\)/i', $file_code, $langs); if (!empty($langs[2])) { $strings = array_merge($strings, $langs[2]); } } } $strings = array_unique($strings); $strings = array_map($prepare, $strings); echo '<textarea rows="20" cols="80">' . implode("\n", $strings) . '</textarea>'; }
public static function on_finalize($controller) { $config = new \GCore\Libs\Parameter($controller->connection['Connection']['extras']['plugins']['download']); $path_field = $config->get('path_field'); $download_action = $config->get('download_action'); if (!empty($path_field) and !empty($download_action)) { if ($controller->action == $download_action) { if (!empty($controller->data['gcb'])) { $path_pcs = explode('.', $path_field); $field = array_pop($path_pcs); $model = array_pop($path_pcs); $row = $controller->connection_models[$model]->load($controller->data['gcb']); if (!empty($row)) { $file_path = \GCore\Libs\Arr::getVal($row, explode('.', $path_field)); if ($config->get('download_path')) { $file_path = rtrim($config->get('download_path'), DS) . DS . $file_path; } if (is_dir($file_path)) { //this is a folder $files = @\GCore\Libs\Folder::getFiles($file_path, false); foreach ($files as $file) { $found[$file] = filemtime($file); } if (empty($found)) { return false; } arsort($found); $files = array_keys($found); sort($files); $file = array_pop($files); \GCore\Libs\Download::send($file, 'D'); } else { //this is a file $file = $file_path; \GCore\Libs\Download::send($file, 'D'); } } } } } }
function delete_cache() { $path = \GCore\C::get('GCORE_FRONT_PATH') . 'cache' . DS; $files = \GCore\Libs\Folder::getFiles($path); $count = 0; foreach ($files as $k => $file) { if (basename($file) != 'index.html' and basename($file) != 'demos.cf5bak') { $result = \GCore\Libs\File::delete($file); if ($result) { $count++; } } } $session = \GCore\Libs\Base::getSession(); $session->setFlash('info', $count . ' ' . l_('CACHE_FILES_DELETED')); $this->redirect(r_('index.php?ext=chronoforms')); }
public function on_list($fld, $ttl, &$data_columns) { $config = new \GCore\Libs\Parameter($this->connection['Connection']['extras']['plugins']['download']); if ($config->get('path_field') and $config->get('download_action')) { $path = $config->get('path_field'); $action = $config->get('download_action'); if ($fld == '_DOWNLOAD_.link') { $link = r_('index.php?ext=chronoconnectivity&cont=lists&act=' . $action . '&ccname=' . $this->connection['Connection']['title'] . '&gcb={' . $this->model->alias . '.' . $this->model->pkey . '}'); $text = $ttl; if ($config->get('display_icon', 1)) { $text = '<i class="fa fa-download fa-fw"></i> ' . $text; } $data_columns[$fld]['html'] = '<a class="' . $config->get('download_link_class', 'btn btn-success btn-xs') . '" href="' . $link . '">' . $text . '</a>'; } $file_info = array(); $file_info['filesize'] = ''; $file_info['filetime'] = ''; $file_info['filename'] = ''; $get_file_info = function ($cell, $row, $column) use($path, $file_info, $config) { $file_path = \GCore\Libs\Arr::getVal($row, explode('.', $path)); if ($config->get('download_path')) { $file_path = rtrim($config->get('download_path'), DS) . DS . $file_path; } //$file_info = array(); if (file_exists($file_path)) { if (is_dir($file_path)) { //this is a folder $files = @\GCore\Libs\Folder::getFiles($file_path, false); foreach ($files as $file) { $found[$file] = filemtime($file); } if (empty($found)) { return false; } arsort($found); $files = array_keys($found); sort($files); $file = array_pop($files); $file_info['filesize'] = \GCore\Libs\File::humanSize(filesize($file)); $file_info['filetime'] = date($config->get('filetime_format', 'd-m-Y H:i'), filemtime($file)); $file_info['filename'] = basename($file); } else { //this is a file $file = $file_path; $file_info['filesize'] = \GCore\Libs\File::humanSize(filesize($file)); $file_info['filetime'] = date($config->get('filetime_format', 'd-m-Y H:i'), filemtime($file)); $file_info['filename'] = basename($file); } } foreach ($file_info as $k => $info) { if ($column == '_DOWNLOAD_.' . $k) { return $file_info[$k]; } } return ''; //$file_info; }; foreach ($file_info as $k => $info) { if ($fld == '_DOWNLOAD_.' . $k) { $data_columns[$fld]['function'] = $get_file_info; } } if ($fld == '_HkkITS_.hot') { $data_columns[$fld]['function'] = create_function('$value,$row', ' if(\\GCore\\Libs\\Arr::getVal($row, explode(".", "' . $download . '"), 0) >= (int)' . $config->get('hot_limit', '1000') . '){ return 1; }else{ return 0; } '); $data_columns[$fld]['html'] = array(0 => '', 1 => '<span class="label label-danger">' . $config->get('hot_text', 'Hot') . '</span>'); } } }