/** * The main method: where things happen * * @access public */ function main() { if (isset($this->params['quiet'])) { $this->quiet = true; } $tmp = new Folder(TMP); $folders = reset($tmp->read()); // read only directories (array[0]) foreach ($folders as $folder) { $tmp->cd(TMP); $tmp->cd($folder); $files = end($tmp->read()); // read only files (array[1]) if (in_array('last_interaction', $files)) { $file_interaction = (int) file_get_contents($tmp->pwd() . DS . 'last_interaction'); // as each piece is 1Mb, this will give the user the chance of uploading at 13,7 kbps (1,7 kb/s) if (time() - $file_interaction > 600) { $this->out("Removing {$folder}"); foreach ($files as $file) { unlink($tmp->pwd() . DS . $file); } $tmp->delete(); } } } }
function getJobs() { App::import('Core', 'Folder'); $Folder = new Folder(); $jobs = array(); if ($Folder->cd(APP . 'vendors' . DS . 'shells' . DS . 'jobs' . DS)) { $x = $Folder->read(true, true, true); $jobs = array_merge($jobs, $x[1]); } if ($Folder->cd(VENDORS . DS . 'shells' . DS . 'jobs' . DS)) { $x = $Folder->read(true, true, true); $jobs = array_merge($jobs, $x[1]); } return $jobs; }
/** * Copy font files used by admin ui * * @throws Exception */ protected function _copyFonts() { $fontAwesomePath = WWW_ROOT . 'fontAwesome'; if (!file_exists($fontAwesomePath)) { if (!$this->_clone) { throw new Exception('You don\'t have "fontAwesome" in ' . WWW_ROOT); } CakeLog::info('Cloning FontAwesome...</info>'); exec('git clone git://github.com/FortAwesome/Font-Awesome ' . $fontAwesomePath); } chdir($fontAwesomePath); exec('git checkout -f master'); $targetPath = WWW_ROOT . 'font' . DS; $Folder = new Folder($targetPath, true); $fontPath = WWW_ROOT . 'fontAwesome' . DS . 'font'; $Folder = new Folder($fontPath); $files = $Folder->read(); if (empty($files[1])) { CakeLog::error('No font files found'); $this->_stop(); } foreach ($files[1] as $file) { $File = new File($fontPath . DS . $file); $newFile = $targetPath . $file; if ($File->copy($newFile)) { $text = __('Font: %s copied', $file); CakeLog::info($text); } else { $text = __('File: %s not copied', $file); CakeLog::error($text); } } }
public function update() { if ($this->type == 'app') { $plugins = CakePlugin::loaded(); } else { $plugins[] = $this->type; } $this->out(__d('cake_console', '<info>-- Migration status in app --</info>')); $this->dispatchShell('Migrations.migration status -i ' . $this->connection); $this->hr(1, 100); if ($this->type == 'app') { $this->out(__d('cake_console', '<info>-- Application core database migrations --</info>')); $this->dispatchShell('Migrations.migration run all -i ' . $this->connection); $this->out(__d('cake_console', '<info>- Application core database updated</info>')); $this->hr(1, 100); } foreach ($plugins as $plugin) { $plugin_migration_folder = new Folder(CakePlugin::path($plugin) . 'Config' . DS . 'Migration'); list($m_folders, $m_files) = $plugin_migration_folder->read(true, array('empty')); if (count($m_files)) { $this->out(__d('cake_console', '<info>-- %s plugin database migrations</info>', $plugin)); $this->dispatchShell('migration run all --plugin ' . $plugin . ' -i ' . $this->connection); $this->out(__d('cake_console', '<info>- %s plugin database updated</info>', $plugin)); $this->hr(1, 100); } } $this->out(__d('cake_console', '<info>-- Build static assets --</info>')); $this->dispatchShell('AssetCompress.AssetCompress build -f'); $this->hr(1, 100); $this->out(__d('cake_console', '<warning>All done</warning>')); }
/** * Loads all available event handler classes for enabled plugins * */ private function __loadEventHandlers() { $this->__eventHandlerCache = Cache::read('event_handlers', 'core'); if (empty($this->__eventHandlerCache)) { App::import('Core', 'Folder'); $folder = new Folder(); $pluginsPaths = App::path('plugins'); foreach ($pluginsPaths as $pluginsPath) { $folder->cd($pluginsPath); $plugins = $folder->read(); $plugins = $plugins[0]; if (count($plugins)) { foreach ($plugins as $pluginName) { $filename = $pluginsPath . $pluginName . DS . $pluginName . '_events.php'; $className = Inflector::camelize($pluginName . '_events'); if (file_exists($filename)) { if (EventCore::__loadEventClass($className, $filename)) { EventCore::__getAvailableHandlers($this->__eventClasses[$className]); } } } } } Cache::write('event_handlers', $this->__eventHandlerCache, 'core'); } }
public function clear() { $this->out("Cleanup CACHE directories"); $dirs = array("models", "persistent", "views"); $i = $failed = 0; foreach ($dirs as $dir) { $this->hr(); $path = CACHE . $dir; if (!is_dir($path)) { $this->out("<error>{$path} is not a directory</error>"); continue; } $this->out("<info>Clear directory {$path}</info>"); $Folder = new Folder($path); list(, $files) = $Folder->read(true, array('.', 'empty'), true); foreach ($files as $file) { if (!unlink($file)) { $failed++; $this->out("<error>Failed to delete file {$file}</error>"); continue; } $this->out("<success>Deleted file {$file}</success>"); $i++; } } $this->out("<success>{$i} files deleted</success>"); $this->out("<error>{$failed} files failed</error>"); $this->hr(); }
/** * undocumented function * * @return void */ function main() { $result = $folder = null; $mainfiles = explode(',', $this->args[0]); $target = !empty($this->params['ext']) ? $this->args[0] . '.' . $this->params['ext'] : $this->args[0] . '.min'; $jsroot = $this->params['working'] . DS . $this->params['webroot'] . DS . 'js' . DS; foreach ((array) $mainfiles as $mainfile) { $mainfile = strpos($mainfile, '/') === false ? $jsroot . $mainfile : $mainfile; $Pack = new File(str_replace('.js', '', $mainfile) . '.js'); $result .= JsMin::minify($Pack->read()); } if (!empty($this->args[1])) { $folder = $this->args[1] . DS; $Js = new Folder($jsroot . $folder); list($ds, $files) = $Js->read(); foreach ((array) $files as $file) { $file = strpos($file, '/') === false ? $jsroot . $folder . $file : $file; $Pack = new File(str_replace('.js', '', $file) . '.js'); $result .= JsMin::minify($Pack->read()); } } $Packed = new File($jsroot . $target . '.js'); if ($Packed->write($result, 'w', true)) { $this->out($Packed->name() . ' created'); } }
/** * Find the paths to all the installed shell themes extensions in the app. * * @return array Array of bake themes that are installed. */ protected function _findSubthemes() { $paths = App::path('shells'); $plugins = App::objects('plugin'); foreach ($plugins as $plugin) { $paths[$plugin] = $this->_pluginPath($plugin) . 'Console' . DS; } foreach ($paths as $i => $path) { $paths[$i] = rtrim($path, DS) . DS; } $subthemes = array(); foreach ($paths as $plugin => $path) { $Folder = new Folder($path . 'SubTemplates', false); $contents = $Folder->read(); $subDirs = $contents[0]; foreach ($subDirs as $dir) { if (empty($dir) || preg_match('@^skel$|_skel|\\..+$@', $dir)) { continue; } $Folder = new Folder($path . 'SubTemplates' . DS . $dir); $contents = $Folder->read(); $subDirs = $contents[0]; $templateDir = $path . 'SubTemplates' . DS . $dir . DS; $subthemes[$plugin . '.' . $dir] = $templateDir; } } return $subthemes; }
public function view($id = null) { $this->layout = 'index'; $this->Anotacion->id = $id; $user = $this->User->findByUsername('transparenciapasiva'); if (!$this->Anotacion->exists() || $this->Anotacion->field('user_id') != $user['User']['id']) { $this->Session->setFlash('<h2 class="alert alert-error">La Anotacion no Existe</h2>', 'default', array(), 'buscar'); $this->redirect(array('controller' => 'home', 'action' => 'index/tab:3')); } $this->set('anotacion', $this->Anotacion->read(null, $id)); $folder_anot = new Folder(WWW_ROOT . 'files' . DS . 'Anotaciones' . DS . 'anot_' . $this->Anotacion->id); $files_url = array(); foreach ($folder_anot->find('.*') as $file) { $files_url[] = basename($folder_anot->pwd()) . DS . $file; } $this->set('files', $files_url); //////////////////////////////////////////////////////////////////// $folder_anot = new Folder(WWW_ROOT . 'files' . DS . 'Anotaciones' . DS . 'anot_' . $this->Anotacion->id . DS . 'Respuestas'); $files_url = array(); $dir = $folder_anot->read(true, false, true); foreach ($dir[0] as $key => $value) { $folder = new Folder($value); foreach ($folder->find('.*') as $file) { $files_url[basename($folder->pwd())][] = $file; } } $this->set('files_res', $files_url); }
/** * Verifica se os menus do banco estão atualizados com os do arquivo * @param $aDados- array de menus do banco * @return boolean */ public function isUpToDate($aDados) { $aDados = Set::combine($aDados, "/Menu/id", "/Menu"); App::import("Xml"); App::import("Folder"); App::import("File"); $sCaminhosArquivos = Configure::read("Cms.CheckPoint.menus"); $oFolder = new Folder($sCaminhosArquivos); $aConteudo = $oFolder->read(); $aArquivos = Set::sort($aConteudo[1], "{n}", "desc"); if (empty($aArquivos)) { return false; } $oFile = new File($sCaminhosArquivos . $aArquivos[0]); $oXml = new Xml($oFile->read()); $aAntigo = $oXml->toArray(); foreach ($aDados as &$aMenu) { $aMenu['Menu']['content'] = str_replace("\r\n", " ", $aMenu['Menu']['content']); } if (isset($aAntigo["menus"])) { $aAntigo["Menus"] = $aAntigo["menus"]; unset($aAntigo["menus"]); } if (isset($aAntigo["Menus"])) { $aAntigo = Set::combine($aAntigo["Menus"], "/Menu/id", "/Menu"); $aRetorno = Set::diff($aDados, $aAntigo); } return empty($aRetorno); }
/** * テーマ一覧 * * @return void * @access public */ function admin_index() { $this->pageTitle = 'テーマ一覧'; $path = WWW_ROOT . 'themed'; $folder = new Folder($path); $files = $folder->read(true, true); foreach ($files[0] as $themename) { if ($themename != 'core') { $themeName = $title = $description = $author = $url = $screenshot = ''; if (file_exists($path . DS . $themename . DS . 'config.php')) { include $path . DS . $themename . DS . 'config.php'; } if (file_exists($path . DS . $themename . DS . 'screenshot.png')) { $theme['screenshot'] = true; } else { $theme['screenshot'] = false; } $theme['name'] = $themename; $theme['title'] = $title; $theme['description'] = $description; $theme['author'] = $author; $theme['url'] = $url; $theme['version'] = $this->getThemeVersion($theme['name']); $themes[] = $theme; } } $themes[] = array('name' => 'core', 'title' => 'BaserCMSコア', 'version' => $this->getBaserVersion(), 'description' => 'BaserCMSのコアファイル。現在のテーマにコピーして利用する事ができます。', 'author' => 'basercms', 'url' => 'http://basercms.net'); $this->set('themes', $themes); $this->subMenuElements = array('site_configs', 'themes'); }
public function beforeFind($queryData) { $this->basePath = Configure::read('Filemanager.base_path'); if (empty($this->basePath)) { $this->validationErrors[] = array('field' => 'basePath', 'message' => __('Base path does not exist')); return false; } $this->path = $this->basePath; if (isset($queryData['conditions']['path'])) { $this->path = $this->basePath . $queryData['conditions']['path']; } App::import('Folder'); App::import('File'); $Folder = new Folder($this->path); if (empty($Folder->path)) { $this->validationErrors[] = array('field' => 'path', 'message' => __('Path does not exist')); return false; } $this->fileList = $Folder->read(); unset($this->fileList[1]); if (!empty($queryData['order'])) { $this->__order($queryData['order']); } return true; }
public function index() { $this->layout = '/xml/sitemap'; $publish_date = date('2016-02-28'); //sitemap公開日を最終更新日用に設定しておく $link_map = $this->Link->find('first', array('conditions' => array('Link.publish' => 1), 'order' => array('Link.modified' => 'desc'))); $erg_lists = $this->Game->find('all', array('conditions' => array('Game.publish' => 1), 'order' => array('Game.modified' => 'desc'), 'fields' => array('Game.id', 'Game.modified'))); $mh_last = $this->Information->find('first', array('conditions' => array('Information.publish' => 1, 'Information.title LIKE' => '%' . 'モンハンメモ' . '%'), 'order' => array('Information.id' => 'desc'))); /* モンハンメモのページ一覧を取得ここから */ $folder = new Folder('../View/mh'); $mh = $folder->read(); foreach ($mh[1] as $key => &$value) { $value = str_replace('.ctp', '', $value); if ($value == 'index') { $index_key = $key; //indexページを後で除くため } } unset($mh[1][$index_key]); $mh_lists = $mh[1]; /* モンハンメモのページ一覧を取得ここまで */ $tool_last = $this->Information->find('first', array('conditions' => array('Information.publish' => 1, 'Information.title LIKE' => '%' . '自作ツール' . '%'), 'order' => array('Information.id' => 'desc'))); /* 自作ツールのページ一覧を取得ここから */ $array_tools = $this->Tool->getArrayTools(); $tool_lists = $array_tools['list']; /* 自作ツールのページ一覧を取得ここまで */ $voice_lists = $this->Voice->find('list', array('conditions' => array('Voice.publish' => 1), 'fields' => 'system_name')); $diary_lists = $this->Diary->find('all', array('conditions' => array('Diary.publish' => 1), 'order' => array('Diary.modified' => 'desc'), 'fields' => array('Diary.id', 'Diary.modified'))); $this->set(compact('publish_date', 'link_map', 'erg_lists', 'mh_last', 'mh_lists', 'tool_last', 'tool_lists', 'voice_lists', 'diary_lists')); $this->RequestHandler->respondAs('xml'); //xmlファイルとして読み込む }
/** * undocumented function * * @return void */ function main() { $choice = ''; $Tasks = new Folder(dirname(__FILE__) . DS . 'tasks'); list($folders, $files) = $Tasks->read(); $i = 1; $choices = array(); foreach ($files as $file) { if (preg_match('/upgrade_/', $file)) { $choices[$i] = basename($file, '.php'); $this->out($i++ . '. ' . basename($file, '.php')); } } while ($choice == '') { $choice = $this->in("Enter a number from the list above, or 'q' to exit", null, 'q'); if ($choice === 'q') { $this->out("Exit"); $this->_stop(); } if ($choice == '' || intval($choice) > count($choices)) { $this->err("The number you selected was not an option. Please try again."); $choice = ''; } } if (intval($choice) > 0 && intval($choice) <= count($choices)) { $upgrade = Inflector::classify($choices[intval($choice)]); } $this->tasks = array($upgrade); $this->loadTasks(); return $this->{$upgrade}->execute(); }
/** * レイアウトテンプレートを取得 * コンボボックスのソースとして利用 * * @return array * @access public */ function getTemplates() { $templatesPathes = array(); if ($this->Baser->siteConfig['theme']) { $templatesPathes[] = WWW_ROOT . 'themed' . DS . $this->Baser->siteConfig['theme'] . DS . 'feed' . DS; } $templatesPathes[] = BASER_PLUGINS . 'feed' . DS . 'views' . DS . 'feed' . DS; $_templates = array(); foreach ($templatesPathes as $templatesPath) { $folder = new Folder($templatesPath); $files = $folder->read(true, true); $foler = null; if ($files[1]) { if ($_templates) { $_templates = am($_templates, $files[1]); } else { $_templates = $files[1]; } } } $templates = array(); foreach ($_templates as $template) { if ($template != 'ajax.ctp' && $template != 'error.ctp') { $template = basename($template, '.ctp'); $templates[$template] = $template; } } return $templates; }
function index() { //get list of plugins $plugins = $this->Plugin->find('all'); $knownPlugins = Set::extract('/Plugin/path', $plugins); //check for new and remove deleted App::import('Core', 'Folder'); $Folder = new Folder(Configure::read('Plugin.path')); $allPlugins = $Folder->read(true, array('.', 'find')); if (!empty($allPlugins[0])) { foreach ($allPlugins[0] as $i => $newPlugin) { if (!in_array($newPlugin, $knownPlugins)) { $NewPlugin = $this->Plugin->load($newPlugin); $this->Plugin->create(); $this->Plugin->save(array('name' => $NewPlugin->name, 'description' => $NewPlugin->description, 'author' => $NewPlugin->author, 'link' => $NewPlugin->link, 'version' => $NewPlugin->version, 'path' => $newPlugin, 'active' => false)); } } } if (!empty($plugins)) { foreach ($plugins as $i => $plugin) { if (empty($allPlugins[0]) || !in_array($plugin['Plugin']['path'], $allPlugins[0])) { $this->Plugin->delete(array('id' => $plugin['Plugin']['id'])); } else { $OldPlugin = $this->Plugin->load($plugin['Plugin']['path']); $plugin['Plugin']['version'] = $OldPlugin->version; $plugin['Plugin']['description'] = $OldPlugin->description; $plugin['Plugin']['author'] = $OldPlugin->author; $plugin['Plugin']['link'] = $OldPlugin->link; $this->Plugin->save($plugin); } } } $this->helpers[] = 'Time'; $this->set('pluginsList', $this->paginate()); }
/** * @return array */ protected function _foldersMabo() { $folder = Configure::read('Tradeplace.maboImportFolder'); $Folder = new Folder($folder); $content = $Folder->read(true, true); return $content[0]; }
/** * testProcessVersion * * @return void */ public function testProcessVersion() { $this->Image->create(); $result = $this->Image->save(array('foreign_key' => 'test-1', 'model' => 'Test', 'file' => array('name' => 'titus.jpg', 'size' => 332643, 'tmp_name' => CakePlugin::path('FileStorage') . DS . 'Test' . DS . 'Fixture' . DS . 'File' . DS . 'titus.jpg', 'error' => 0))); $result = $this->Image->find('first', array('conditions' => array('id' => $this->Image->getLastInsertId()))); $this->assertTrue(!empty($result) && is_array($result)); $this->assertTrue(file_exists($this->testPath . $result['ImageStorage']['path'])); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 3); Configure::write('Media.imageSizes.Test', array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200)))); ClassRegistry::init('FileStorage.ImageStorage')->generateHashes(); $Event = new CakeEvent('ImageVersion.createVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))))); CakeEventManager::instance()->dispatch($Event); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 4); $Event = new CakeEvent('ImageVersion.removeVersion', $this->Image, array('record' => $result, 'storage' => StorageManager::adapter('Local'), 'operations' => array('t200' => array('thumbnail' => array('mode' => 'outbound', 'width' => 200, 'height' => 200))))); CakeEventManager::instance()->dispatch($Event); $path = $this->testPath . $result['ImageStorage']['path']; $Folder = new Folder($path); $folderResult = $Folder->read(); $this->assertEqual(count($folderResult[1]), 3); }
/** * レイアウトテンプレートを取得 * コンボボックスのソースとして利用 * * @return array レイアウトの一覧データ */ public function getTemplates() { $templatesPathes = array(); if ($this->BcBaser->siteConfig['theme']) { $templatesPathes[] = WWW_ROOT . 'theme' . DS . $this->BcBaser->siteConfig['theme'] . DS . 'Feed' . DS; } $templatesPathes[] = BASER_PLUGINS . 'Feed' . DS . 'View' . DS . 'Feed' . DS; $_templates = array(); foreach ($templatesPathes as $templatesPath) { $folder = new Folder($templatesPath); $files = $folder->read(true, true); $foler = null; if ($files[1]) { if ($_templates) { $_templates = am($_templates, $files[1]); } else { $_templates = $files[1]; } } } $templates = array(); foreach ($_templates as $template) { $ext = Configure::read('BcApp.templateExt'); if ($template != 'ajax' . $ext && $template != 'error' . $ext) { $template = basename($template, $ext); $templates[$template] = $template; } } return $templates; }
public function execute() { // I18nProfile class: http://stackoverflow.com/questions/8433686/is-there-a-php-library-for-parsing-gettext-po-pot-files App::import('Lib', 'I18nJs.PoParser'); $dir = new Folder(APP . 'Locale'); $locales = $dir->read(); foreach ($locales[0] as $localeDir) { $msgids = array(); $language = $localeDir; $localeDir = new Folder(APP . 'Locale' . DS . $localeDir); $files = $localeDir->findRecursive('i18n_js.*\\.po'); // Loop over PO i18n_js PO files foreach ($files as $file) { $file = new File($file); // Get language if (preg_match('%Locale/(.*?)/LC_MESSAGES%', $file->path, $regs)) { $language = $regs[1]; } else { // todo return $this->out(__d('i18n_js', '<error>Unable to determine language of PO file:</error>') . $file->path); return; } // Get context, domain $context = ''; if (strpos($file->name(), '.')) { $context = explode('.', $file->name()); $context = $context[1]; } // Parse PO file $poparser = new \Sepia\PoParser(); $translations = $poparser->parse($file->path); foreach ($translations as $key => $translation) { if (empty($key)) { continue; } if (is_array($translation['msgid'])) { $translation['msgid'] = implode('', $translation['msgid']); } if (is_array($translation['msgstr'])) { $translation['msgstr'] = implode('', $translation['msgstr']); } $msgids[$context][$translation['msgid']] = $translation['msgstr']; } } if (empty($msgids)) { continue; } // Write JS file $outputFile = new File(WWW_ROOT . 'js' . DS . 'Locale' . DS . 'i18n_js.' . $language . '.js', true); $data = "I18nJs.locale = { "; $data .= "'pluralFormula': function (\$n) { return Number((\$n != 1)); }, "; $data .= "'strings': " . json_encode($msgids, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT) . " };"; if ($outputFile->write($data)) { $this->out(__d('i18n_js', '<info>%s created</info>', $outputFile->path)); } else { $this->out(__d('i18n_js', '<error>Unable to write: %s</error>', $outputFile->path)); } } }
public function login() { if ($this->request->is('post')) { if ($this->Auth->login()) { /* ログイン時に定期バックアップを判定して作成ここから */ $file_pass = '******'; $file_name = 'sister_backup'; $backup_flg = 1; $folder = new Folder($file_pass); $lists = $folder->read(); foreach ($lists[1] as $list) { //ファイル名から日付を取得 $name = str_replace(array($file_name . '_', '.txt'), '', $list); if (date('Ymd', strtotime('-7 day')) < date($name)) { //直近のファイルがあればflgを消去 $backup_flg = 0; break; } } if ($backup_flg == 1) { //flgがあればバックアップを作成 //DBデータを取得する $array_model = array('Administrator', 'Banner', 'Birthday', 'Diary', 'DiaryGenre', 'Game', 'Information', 'Link', 'Maker', 'Music', 'Photo', 'Product', 'SisterComment', 'Voice'); foreach ($array_model as $model) { $this->{$model}->Behaviors->disable('SoftDelete'); $datas = $this->{$model}->find('all', array('order' => $model . '.id', 'recursive' => -1)); $this->set($model . '_datas', $datas); $this->set($model . '_tbl', $this->{$model}->useTable); } $this->set('array_model', $array_model); $this->layout = false; $sql = $this->render('sql_backup'); $file = new File($file_pass . '/' . $file_name . '_' . date('Ymd') . '.sql', true); if ($file->write($sql)) { //バックアップ成功時の処理 $file->close(); foreach ($lists[1] as $list) { $file = new File($file_pass . '/' . $list); $file->delete(); $file->close(); } } else { //バックアップ失敗時の処理 $file->close(); $admin_mail = Configure::read('admin_mail'); $email = new CakeEmail('gmail'); $email->to($admin_mail)->subject('【虹妹prprシステム通知】バックアップエラー通知')->template('backup_error', 'sister_mail')->viewVars(array('name' => '管理者')); //mailに渡す変数 $email->send(); } } /* ログイン時に定期バックアップを判定して作成ここまで */ $this->redirect($this->Auth->redirect()); } else { $this->Flash->error(__('ユーザ名かパスワードが間違っています。')); $this->redirect('/login/'); } } }
function _languages() { // Load library App::uses('Folder', 'Utility'); $folder = new Folder(APP . 'Locale'); $ls = $folder->read(true); return $ls[0]; }
/** * Adds all the files in a directory to the test suite. Does not recurse through directories. * * @param string $directory The directory to add tests from. * @return void */ public function addTestDirectory($directory = '.') { $Folder = new Folder($directory); list($dirs, $files) = $Folder->read(true, true, true); foreach ($files as $file) { $this->addTestFile($file); } }
public function paginateCount($conditions = null, $recursive = 0, $extra = array()) { App::import('Core', 'Folder'); $Folder = new Folder($this->__path()); $pages = $Folder->read(); unset($Folder); return count($pages[1]); }
public function index() { //ダッシュボード用(件数取得) $this->set('comment_count', $this->SisterComment->find('count')); $this->set('comment_p_count', $this->SisterComment->find('count', array('conditions' => array('SisterComment.publish' => 1)))); $this->set('banner_count', $this->Banner->find('count')); $this->set('banner_p_count', $this->Banner->find('count', array('conditions' => array('Banner.publish' => 1)))); $this->set('game_count', $this->Game->find('count')); $this->set('game_p_count', $this->Game->find('count', array('conditions' => array('Game.publish' => 1)))); $this->set('maker_count', $this->Maker->find('count')); $this->set('maker_p_count', $this->Maker->find('count', array('conditions' => array('Maker.publish' => 1)))); $folder = new Folder('../View/mh'); //ディレクトリのファイル数から取得 $mh = $folder->read(); $this->set('mh_count', count($mh[1]) - 1); $array_tools = $this->Tool->getArrayTools(); $this->set('tool_count', $array_tools['count']); //urlが設定されてなければ公開前と判断してcountを-1 foreach ($array_tools['list'] as $tool) { if (!$tool['url']) { $array_tools['count']--; } } $this->set('tool_p_count', $array_tools['count']); $voice_lists = $this->Voice->find('all'); foreach ($voice_lists as $voice_list) { $this->set($voice_list['Voice']['system_name'] . '_count', $this->Product->find('count', array('conditions' => array('Product.voice_id' => $voice_list['Voice']['id'])))); $this->set($voice_list['Voice']['system_name'] . '_p_count', $this->Product->find('count', array('conditions' => array('Product.voice_id' => $voice_list['Voice']['id'], 'Product.publish' => 1)))); //コンテンツ自体が非公開の場合 if ($voice_list['Voice']['publish'] == 0) { $this->set($voice_list['Voice']['system_name'] . '_p_count', 0); } } $this->set('diary_count', $this->Diary->find('count')); $this->set('diary_p_count', $this->Diary->find('count', array('conditions' => array('Diary.publish' => 1)))); $this->set('photo_count', $this->Photo->find('count')); //ダッシュボード用(最終更新) $comment_last = $this->SisterComment->find('first', array('order' => array('SisterComment.modified' => 'desc'))); $this->set('comment_lastupdate', $comment_last ? $comment_last['SisterComment']['modified'] : null); $banner_last = $this->Banner->find('first', array('order' => array('Banner.modified' => 'desc'))); $this->set('banner_lastupdate', $banner_last ? $banner_last['Banner']['modified'] : null); $game_last = $this->Game->find('first', array('order' => array('Game.modified' => 'desc'))); $this->set('game_lastupdate', $game_last ? $game_last['Game']['modified'] : null); $maker_last = $this->Maker->find('first', array('order' => array('Maker.modified' => 'desc'))); $this->set('maker_lastupdate', $maker_last ? $maker_last['Maker']['modified'] : null); $mh_last = $this->Information->find('first', array('conditions' => array(array('or' => array('Information.date_from <=' => date('Y-m-d'), 'Information.date_from' => null)), 'Information.publish' => 1, 'Information.title LIKE' => '%' . 'モンハンメモ' . '%'), 'order' => array('Information.id' => 'desc'))); $this->set('mh_lastupdate', $mh_last ? $mh_last['Information']['created'] : null); $tool_last = $this->Information->find('first', array('conditions' => array(array('or' => array('Information.date_from <=' => date('Y-m-d'), 'Information.date_from' => null)), 'Information.publish' => 1, 'Information.title LIKE' => '%' . '自作ツール' . '%'), 'order' => array('Information.id' => 'desc'))); $this->set('tool_lastupdate', $tool_last ? $tool_last['Information']['created'] : null); foreach ($voice_lists as $voice_list) { ${$voice_list['Voice']['system_name'] . '_last'} = $this->Product->find('first', array('order' => array('Product.modified' => 'desc'), 'conditions' => array('Product.voice_id' => $voice_list['Voice']['id']))); $this->set($voice_list['Voice']['system_name'] . '_lastupdate', ${$voice_list['Voice']['system_name'] . '_last'} ? ${$voice_list['Voice']['system_name'] . '_last'}['Product']['modified'] : null); } $diary_last = $this->Diary->find('first', array('order' => array('Diary.modified' => 'desc'))); $this->set('diary_lastupdate', $diary_last ? $diary_last['Diary']['modified'] : null); $photo_last = $this->Photo->find('first', array('order' => array('Photo.modified' => 'desc'))); $this->set('photo_lastupdate', $photo_last ? $photo_last['Photo']['modified'] : null); }
public function index() { $actorsFolder = IMAGES . "actors"; if (!is_dir($actorsFolder)) { mkdir($actorsFolder, 775, true); } $actorsImages = new Folder($actorsFolder); $this->set("actorsImages", json_encode(end($actorsImages->read(true, true)))); }
public function listar($idConvenio) { $dir = new Folder(WWW_ROOT . 'xml/' . $idConvenio); $path = $dir->pwd() . '\\'; $files = $dir->read(true); $this->set('idConvenio', $idConvenio); $this->set('path', $path); $this->set('files', $files); }
public function tearDown() { parent::tearDown(); //cleanup attachmentDir $Folder = new Folder($this->attachmentDir); list($dir, $files) = $Folder->read(true, array('empty'), true); foreach ($files as $file) { @unlink($file); } }
/** * Adds all the files in a directory to the test suite. Does not recurse through directories. * * @param string $directory The directory to add tests from. * @return void */ public function addTestDirectory($directory = '.') { $Folder = new Folder($directory); list(, $files) = $Folder->read(true, true, true); foreach ($files as $file) { if (substr($file, -4) === '.php') { $this->addTestFile($file); } } }
/** * テーマの一覧を取得する */ public function testGetTheme() { $results = $this->SiteConfig->getThemes(); $Folder = new Folder(BASER_CONFIGS . 'theme'); $files = $Folder->read(true, true, false); $expected = []; foreach ($files[0] as $file) { $this->assertContains(Inflector::camelize($file), $results); $this->assertArrayHasKey($file, $results); } }