/** * Override loadTasks() to handle paths * * @access public */ function loadTasks() { parent::loadTasks(); $task = Inflector::classify($this->command); if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) { if (empty($this->{$task}->path)) { $path = Inflector::underscore(Inflector::pluralize($this->command)); $this->{$task}->path = $this->params['working'] . DS . $path . DS; } if (isset($this->params['connection'])) { $this->{$task}->connection = $this->params['connection']; } foreach ($this->args as $i => $arg) { if (strpos($arg, '.')) { list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg); break; } } if (isset($this->params['plugin'])) { $this->{$task}->plugin = $this->params['plugin']; } if (!is_dir($this->{$task}->path)) { $this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path)); $this->_stop(); } } }
function main() { parent::loadTasks(); $this->out('Import Upload Shell'); $this->hr(); $this->_setAvailableImportFiles(); if (empty($this->args)) { $imports = $this->_interactive(); } else { $imports = $this->_determineImportIds(implode(' ', $this->args)); } if (!empty($imports)) { foreach ($imports as $import) { $importUpload = $this->ImportUpload->create($import); if ($filename = $this->ImportUpload->filePath()) { $importUpload['ImportUpload']['file_path'] = $filename; if (!empty($import['ImportDelimiter'])) { $options = array('delimiter' => $import['ImportDelimiter']['delimiter'], 'excel_reader' => $import['ImportDelimiter']['use_excel_reader'], 'qualifier' => $import['ImportUpload']['text_qualifier']); } if ($this->Parser->execute($filename, $options)) { $this->ImportUpload->saveField('total', $this->Parser->getRowCount()); $this->ImportUpload->saveField('is_importing', 1); } die('here'); } else { } } } }
/** * The main function, executed automatically when running the shell * */ function main() { parent::loadTasks(); $this->out('Build Search Index Shell'); $this->hr(); // Figure out which db config we are using $this->_setDbConfig(); // Determine the models for the selected db config that have Searchable $this->_setAvailableModels(); // If no args on command line, run interactively if (empty($this->args)) { $modelNames = $this->_interactive(); } else { // Pass command line args off to validate input $modelNames = $this->_determineModelnames(implode(' ', $this->args)); } foreach ($modelNames as $modelName) { // Confirm rebuild index for this model $skip = $this->in(__("Are you sure you want to rebuild the search index for {$modelName}, 'y' or 'n' or 'q' to exit", true), null, 'n'); // Quit if they want to if (strtolower($skip) === 'q') { $this->out(__("Exit", true)); $this->_stop(); } // Skip if they want to if (strtolower($skip) !== 'y') { $this->out(__("Skipping " . $modelName, true)); continue; } // Instantiate the model object $ModelObj = ClassRegistry::init($modelName); // Delete the records in the search index for the current model if (!$ModelObj->deleteSearchIndex(true)) { $this->err(__('Could not delete search index', true)); $this->_stop(); } // Find all records if (method_exists($ModelObj, 'getAllSearchableData')) { $records = $ModelObj->getAllSearchableData(); } else { $records = $ModelObj->find('all', array('recursive' => 0)); } foreach ($records as $record) { // Set model->data property $ModelObj->set($record); // Set the _records property of the Searchable Behavior $ModelObj->setSearchableRecords(false, true); // Save the search index record $ModelObj->saveSearchIndex(true); // Report progress $this->out($ModelObj->alias . ' ' . $ModelObj->id . ' ' . $record[$ModelObj->alias][$ModelObj->displayField]); } } $this->hr(); }
/** * Override loadTasks() to handle paths * * @access public */ function loadTasks() { parent::loadTasks(); $task = Inflector::classify($this->command); if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) { $path = Inflector::underscore(Inflector::pluralize($this->command)); $this->{$task}->path = $this->params['working'] . DS . $path . DS; if (!is_dir($this->{$task}->path)) { $this->err(sprintf(__("%s directory could not be found.\nBe sure you have created %s", true), $task, $this->{$task}->path)); exit; } } }
function loadTasks() { Configure::write('debug', 0); //設置されているプラグインを取得 $this->installed_plugins = getPlugins(); foreach ($this->installed_plugins as $plugin) { $taskPath = APP . 'plugins' . DS . $plugin . DS . 'vendors' . DS . 'shells' . DS; $installerPath = APP . 'plugins' . DS . $plugin . DS . 'vendors' . DS . 'shells' . DS . 'tasks' . DS . "install_{$plugin}.php"; if (file_exists($installerPath)) { $this->Dispatch->shellPaths[] = $taskPath; $this->tasks[] = $this->getPluginInstallerTaskName($plugin); } } parent::loadTasks(); }
/** * Override loadTasks() to handle paths * * @access public */ function loadTasks() { parent::loadTasks(); $task = Inflector::classify($this->command); if (isset($this->{$task}) && !in_array($task, array('Project', 'DbConfig'))) { if (isset($this->params['connection'])) { $this->{$task}->connection = $this->params['connection']; } foreach($this->args as $i => $arg) { if (strpos($arg, '.')) { list($this->params['plugin'], $this->args[$i]) = pluginSplit($arg); break; } } if (isset($this->params['plugin'])) { $this->{$task}->plugin = $this->params['plugin']; } } }
/** * loadTasks method * * @return void * @access public */ function loadTasks() { parent::loadTasks(); foreach ($this->Find->settings as $key => $val) { if (isset($this->settings[$key])) { $this->Find->settings[$key] =& $this->settings[$key]; } } $this->Find->startup(); }