/** * loadConfig * * @param string $name * @access public * @return void */ public function loadConfig($name = '') { $baseDir = PATH_APP . DS . 'config' . DS . 'search' . DS . 'types'; if ($name == '') { $configFiles = Filesystem::listContents($baseDir); $config = array(); foreach ($configFiles as $file) { if (Filesystem::extension($baseDir . $file['path']) == 'php') { $typeConfig = (require_once $baseDir . $file['path']); array_push($config, $typeConfig); } } return $config; } elseif ($name != '') { $filename = $baseDir . DS . $name . '.php'; if (Filesystem::exists($filename)) { $config = (include $filename); } else { $config = false; } return $config; } return false; }
/** * Edit Newsletter Story Task * * @return void */ public function editTask() { //get request vars $this->view->type = strtolower(Request::getVar("type", "primary")); $this->view->id = Request::getInt("id", 0); $this->view->sid = Request::getInt("sid", 0); //load campaign $this->view->newsletter = new Newsletter($this->database); $this->view->newsletter->load($this->view->id); //default object $this->view->story = new stdClass(); $this->view->story->id = null; $this->view->story->order = null; $this->view->story->title = null; $this->view->story->story = null; $this->view->story->readmore_title = null; $this->view->story->readmore_link = null; //are we editing if ($this->view->sid) { if ($this->view->type == "primary") { $this->view->story = new PrimaryStory($this->database); } else { $this->view->story = new SecondaryStory($this->database); } $this->view->story->load($this->view->sid); } // Set any errors if ($this->getError()) { $this->view->setError($this->getError()); } // If we are creating an auto-generated newsletter if ($this->view->type == 'autogen') { // Load available sources $this->view->enabledSources = Event::trigger('newsletter.onGetEnabledDigests'); /* It should be noted that these are not served via the CMS, per se. Rather they * JavaScript will manipulate the DOM and save the HTML as a string into the Primary * Story content field. */ // The path where the Story Template Layouts are. $viewPath = dirname(__DIR__) . DS . 'views' . DS . 'storytemplates' . DS . 'tmpl'; // Get available layouts $contents = Filesystem::listContents($viewPath); // Empty bucket to hold layout names; $this->view->layouts = array(); // Make sure we aren't including any cruft. foreach ($contents as $file) { // Check for php extention if (Filesystem::extension($viewPath . DS . $file['path']) == 'php' && $file['path'] != '/index.php') { // Some trimming of the leading / and the .php; push into bucket array_push($this->view->layouts, rtrim(ltrim($file['path'], "//"), ".php")); } } // Display the alternative layout $this->view->setLayout('_autogen')->display(); } else { // Output the HTML $this->view->setLayout('edit')->display(); } }
public function testNoop() { $filesystem = new Filesystem(new Adapter\Local(__DIR__ . '/files'), new Cache\Noop()); $filesystem->write('test.txt', 'contents'); $this->assertTrue($filesystem->has('test.txt')); $this->assertInternalType('array', $filesystem->listContents()); $cache = $filesystem->getCache(); $cache->setComplete('', false); $cache->flush(); $cache->autosave(); $this->assertFalse($cache->isComplete('', false)); $this->assertFalse($cache->read('something')); $this->assertFalse($cache->getMetadata('something')); $this->assertFalse($cache->getMimetype('something')); $this->assertFalse($cache->getSize('something')); $this->assertFalse($cache->getTimestamp('something')); $this->assertFalse($cache->getVisibility('something')); $this->assertFalse($cache->listContents('', false)); $filesystem->delete('test.txt'); }