当前位置: 首页>>代码示例>>PHP>>正文


PHP SpoonFile::exists方法代码示例

本文整理汇总了PHP中SpoonFile::exists方法的典型用法代码示例。如果您正苦于以下问题:PHP SpoonFile::exists方法的具体用法?PHP SpoonFile::exists怎么用?PHP SpoonFile::exists使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpoonFile的用法示例。


在下文中一共展示了SpoonFile::exists方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: loadConfig

 /**
  * Load the config file for the requested module.
  * In the config file we have to find disabled actions, the constructor will read the folder
  * and set possible actions. Other configurations will also be stored in it.
  */
 public function loadConfig()
 {
     // check if module path is not yet defined
     if (!defined('BACKEND_MODULE_PATH')) {
         // build path for core
         if ($this->getModule() == 'core') {
             define('BACKEND_MODULE_PATH', BACKEND_PATH . '/' . $this->getModule());
         } else {
             define('BACKEND_MODULE_PATH', BACKEND_MODULES_PATH . '/' . $this->getModule());
         }
     }
     // check if the config is present? If it isn't present there is a huge problem, so we will stop our code by throwing an error
     if (!SpoonFile::exists(BACKEND_MODULE_PATH . '/config.php')) {
         throw new BackendException('The configfile for the module (' . $this->getModule() . ') can\'t be found.');
     }
     // build config-object-name
     $configClassName = 'Backend' . SpoonFilter::toCamelCase($this->getModule() . '_config');
     // require the config file, we validated before for existence.
     require_once BACKEND_MODULE_PATH . '/config.php';
     // validate if class exists (aka has correct name)
     if (!class_exists($configClassName)) {
         throw new BackendException('The config file is present, but the classname should be: ' . $configClassName . '.');
     }
     // create config-object, the constructor will do some magic
     $this->config = new $configClassName($this->getModule());
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:31,代码来源:ajax_action.php

示例2: loadData

 /**
  * Load the data.
  * This will also set some warnings if needed.
  */
 private function loadData()
 {
     // inform that the theme is not installed yet
     if (!BackendExtensionsModel::isThemeInstalled($this->currentTheme)) {
         $this->warnings[] = array('message' => BL::getMessage('InformationThemeIsNotInstalled'));
     }
     // path to information file
     $pathInfoXml = FRONTEND_PATH . '/themes/' . $this->currentTheme . '/info.xml';
     // information needs to exists
     if (SpoonFile::exists($pathInfoXml)) {
         try {
             // load info.xml
             $infoXml = @new SimpleXMLElement($pathInfoXml, LIBXML_NOCDATA, true);
             // convert xml to useful array
             $this->information = BackendExtensionsModel::processThemeXml($infoXml);
             // empty data (nothing useful)
             if (empty($this->information)) {
                 $this->warnings[] = array('message' => BL::getMessage('InformationFileIsEmpty'));
             }
         } catch (Exception $e) {
             $this->warnings[] = array('message' => BL::getMessage('InformationFileCouldNotBeLoaded'));
         }
     } else {
         $this->warnings[] = array('message' => BL::getMessage('InformationFileIsMissing'));
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:30,代码来源:detail_theme.php

示例3: getCM

 /**
  * Returns the CampaignMonitor object
  *
  * @param int[optional] $listId The default list id to use.
  * @return CampaignMonitor
  */
 public static function getCM($listId = null)
 {
     // campaignmonitor reference exists
     if (!Spoon::exists('campaignmonitor')) {
         // check if the CampaignMonitor class exists
         if (!SpoonFile::exists(PATH_LIBRARY . '/external/campaignmonitor.php')) {
             // the class doesn't exist, so throw an exception
             throw new SpoonFileException('The CampaignMonitor wrapper class is not found. Please locate and place it in /library/external');
         }
         // require CampaignMonitor class
         require_once 'external/campaignmonitor.php';
         // set login data
         $url = FrontendModel::getModuleSetting('mailmotor', 'cm_url');
         $username = FrontendModel::getModuleSetting('mailmotor', 'cm_username');
         $password = FrontendModel::getModuleSetting('mailmotor', 'cm_password');
         // init CampaignMonitor object
         $cm = new CampaignMonitor($url, $username, $password, 5, self::getClientId());
         // set CampaignMonitor object reference
         Spoon::set('campaignmonitor', $cm);
         // get the default list ID
         $listId = !empty($listId) ? $listId : self::getDefaultListID();
         // set the default list ID
         $cm->setListId($listId);
     }
     // return the CampaignMonitor object
     return Spoon::get('campaignmonitor');
 }
开发者ID:nickmancol,项目名称:forkcms-rhcloud,代码行数:33,代码来源:helper.php

示例4: loadData

 /**
  * Load the data.
  * This will also set some warnings if needed.
  */
 private function loadData()
 {
     // inform that the module is not installed yet
     if (!BackendExtensionsModel::isModuleInstalled($this->currentModule)) {
         $this->warnings[] = array('message' => BL::getMessage('InformationModuleIsNotInstalled'));
     }
     // path to information file
     $pathInfoXml = BACKEND_MODULES_PATH . '/' . $this->currentModule . '/info.xml';
     // information needs to exists
     if (SpoonFile::exists($pathInfoXml)) {
         try {
             // load info.xml
             $infoXml = @new SimpleXMLElement($pathInfoXml, LIBXML_NOCDATA, true);
             // convert xml to useful array
             $this->information = BackendExtensionsModel::processModuleXml($infoXml);
             // empty data (nothing useful)
             if (empty($this->information)) {
                 $this->warnings[] = array('message' => BL::getMessage('InformationFileIsEmpty'));
             }
             // check if cronjobs are installed already
             if (isset($this->information['cronjobs'])) {
                 foreach ($this->information['cronjobs'] as $cronjob) {
                     if (!$cronjob['active']) {
                         $this->warnings[] = array('message' => BL::getError('CronjobsNotSet'));
                     }
                     break;
                 }
             }
         } catch (Exception $e) {
             $this->warnings[] = array('message' => BL::getMessage('InformationFileCouldNotBeLoaded'));
         }
     } else {
         $this->warnings[] = array('message' => BL::getMessage('InformationFileIsMissing'));
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:39,代码来源:detail_module.php

示例5: getWarnings

 /**
  * Get warnings for active modules
  *
  * @return	array
  */
 public static function getWarnings()
 {
     // init vars
     $warnings = array();
     $activeModules = BackendModel::getModules(true);
     // add warnings
     $warnings = array_merge($warnings, BackendModel::checkSettings());
     // loop active modules
     foreach ($activeModules as $module) {
         // model class
         $class = 'Backend' . SpoonFilter::toCamelCase($module) . 'Model';
         // model file exists
         if (SpoonFile::exists(BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php')) {
             // require class
             require_once BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php';
         }
         // method exists
         if (is_callable(array($class, 'checkSettings'))) {
             // add possible warnings
             $warnings = array_merge($warnings, call_user_func(array($class, 'checkSettings')));
         }
     }
     // return
     return (array) $warnings;
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:30,代码来源:model.php

示例6: getPath

 /**
  * Get the file path based on the theme.
  * If it does not exist in the theme it will return $file.
  *
  * @return	string					Path to the (theme) file.
  * @param	string $file			Path to the file.
  */
 public static function getPath($file)
 {
     // redefine
     $file = (string) $file;
     // theme name
     $theme = self::getTheme();
     // theme in use
     if (FrontendModel::getModuleSetting('core', 'theme', 'core') != 'core') {
         // theme not yet specified
         if (strpos($file, 'frontend/themes/' . $theme) === false) {
             // add theme location
             $themeTemplate = str_replace(array('frontend/'), array('frontend/themes/' . $theme . '/'), $file);
             // check if this template exists
             if (SpoonFile::exists(PATH_WWW . str_replace(PATH_WWW, '', $themeTemplate))) {
                 $file = $themeTemplate;
             }
         }
     }
     // check if the file exists
     if (!SpoonFile::exists(PATH_WWW . str_replace(PATH_WWW, '', $file))) {
         throw new FrontendException('The template (' . $file . ') doesn\'t exists.');
     }
     // return template path
     return $file;
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:32,代码来源:theme.php

示例7: validateInstall

 /**
  * Validate if the theme can be installed.
  */
 private function validateInstall()
 {
     // already installed
     if (BackendExtensionsModel::isThemeInstalled($this->currentTheme)) {
         $this->redirect(BackendModel::createURLForAction('themes') . '&error=already-installed&var=' . $this->currentTheme);
     }
     // no information file present
     if (!SpoonFile::exists(FRONTEND_PATH . '/themes/' . $this->currentTheme . '/info.xml')) {
         $this->redirect(BackendModel::createURLForAction('themes') . '&error=no-information-file&var=' . $this->currentTheme);
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:14,代码来源:install_theme.php

示例8: validateInstall

 /**
  * Validate if the module can be installed.
  */
 private function validateInstall()
 {
     // already installed
     if (BackendExtensionsModel::isModuleInstalled($this->currentModule)) {
         $this->redirect(BackendModel::createURLForAction('modules') . '&error=already-installed&var=' . $this->currentModule);
     }
     // no installer class present
     if (!SpoonFile::exists(BACKEND_MODULES_PATH . '/' . $this->currentModule . '/installer/installer.php')) {
         $this->redirect(BackendModel::createURLForAction('modules') . '&error=no-installer-file&var=' . $this->currentModule);
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:14,代码来源:install_module.php

示例9: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // get parameters
     $url = SpoonFilter::getPostValue('url', null, '');
     $username = SpoonFilter::getPostValue('username', null, '');
     $password = SpoonFilter::getPostValue('password', null, '');
     // filter out the 'http://' from the URL
     if (strpos($url, 'http://') !== false) {
         $url = str_replace('http://', '', $url);
     }
     if (strpos($url, 'https://') !== false) {
         $url = str_replace('https://', '', $url);
     }
     // check input
     if (empty($url)) {
         $this->output(self::BAD_REQUEST, array('field' => 'url'), BL::err('NoCMAccountCredentials'));
     }
     if (empty($username)) {
         $this->output(self::BAD_REQUEST, array('field' => 'username'), BL::err('NoCMAccountCredentials'));
     }
     if (empty($password)) {
         $this->output(self::BAD_REQUEST, array('field' => 'password'), BL::err('NoCMAccountCredentials'));
     }
     try {
         // check if the CampaignMonitor class exists
         if (!SpoonFile::exists(PATH_LIBRARY . '/external/campaignmonitor.php')) {
             // the class doesn't exist, so stop here
             $this->output(self::BAD_REQUEST, null, BL::err('ClassDoesNotExist', $this->getModule()));
         }
         // require CampaignMonitor class
         require_once 'external/campaignmonitor.php';
         // init CampaignMonitor object
         new CampaignMonitor($url, $username, $password, 10);
         // save the new data
         BackendModel::setModuleSetting($this->getModule(), 'cm_url', $url);
         BackendModel::setModuleSetting($this->getModule(), 'cm_username', $username);
         BackendModel::setModuleSetting($this->getModule(), 'cm_password', $password);
         // account was linked
         BackendModel::setModuleSetting($this->getModule(), 'cm_account', true);
     } catch (Exception $e) {
         // timeout occured
         if ($e->getMessage() == 'Error Fetching http headers') {
             $this->output(self::BAD_REQUEST, null, BL::err('CmTimeout', $this->getModule()));
         }
         // other error
         $this->output(self::ERROR, array('field' => 'url'), sprintf(BL::err('CampaignMonitorError', $this->getModule()), $e->getMessage()));
     }
     // trigger event
     BackendModel::triggerEvent($this->getModule(), 'after_account_linked');
     // CM was successfully initialized
     $this->output(self::OK, array('message' => 'account-linked'), BL::msg('AccountLinked', $this->getModule()));
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:56,代码来源:link_account.php

示例10: processFile

 /**
  * Process the content of the file.
  *
  * @param string $file The file to process.
  * @return boolean|array
  */
 private function processFile($file)
 {
     // if the files doesn't exists we can stop here and just return an empty string
     if (!SpoonFile::exists($file)) {
         return array();
     }
     // fetch content from file
     $content = SpoonFile::getContent($file);
     $json = @json_decode($content, true);
     // skip invalid JSON
     if ($json === false || $json === null) {
         return array();
     }
     $return = array();
     // loop templates
     foreach ($json as $template) {
         // skip items without a title
         if (!isset($template['title'])) {
             continue;
         }
         if (isset($template['file'])) {
             if (SpoonFile::exists(PATH_WWW . $template['file'])) {
                 $template['html'] = SpoonFile::getContent(PATH_WWW . $template['file']);
             }
         }
         // skip items without HTML
         if (!isset($template['html'])) {
             continue;
         }
         $image = '';
         if (isset($template['image'])) {
             // we have to remove the first slash, because that is set in the wrapper. Otherwise the images don't work
             $image = ltrim($template['image'], '/');
         }
         $temp['title'] = $template['title'];
         $temp['description'] = isset($template['description']) ? $template['description'] : '';
         $temp['image'] = $image;
         $temp['html'] = $template['html'];
         // add the template
         $return[] = $temp;
     }
     return $return;
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:49,代码来源:templates.php

示例11: loadDataGrid

 /**
  * Load the datagrid
  *
  * @return	void
  */
 private function loadDataGrid()
 {
     // init var
     $items = array();
     // get active modules
     $modules = BackendModel::getModules();
     // loop active modules
     foreach ($modules as $module) {
         // check if their is a model-file
         if (SpoonFile::exists(BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php')) {
             // require the model-file
             require_once BACKEND_MODULES_PATH . '/' . $module . '/engine/model.php';
             // build class name
             $className = SpoonFilter::toCamelCase('backend_' . $module . '_model');
             // check if the getByTag-method is available
             if (is_callable(array($className, 'getByTag'))) {
                 // make the call and get the item
                 $moduleItems = (array) call_user_func(array($className, 'getByTag'), $this->id);
                 // loop items
                 foreach ($moduleItems as $row) {
                     // check if needed fields are available
                     if (isset($row['url'], $row['name'], $row['module'])) {
                         // add
                         $items[] = array('module' => ucfirst(BL::lbl(SpoonFilter::toCamelCase($row['module']))), 'name' => $row['name'], 'url' => $row['url']);
                     }
                 }
             }
         }
     }
     // create datagrid
     $this->dgUsage = new BackendDataGridArray($items);
     // disable paging
     $this->dgUsage->setPaging(false);
     // hide columns
     $this->dgUsage->setColumnsHidden(array('url'));
     // set headers
     $this->dgUsage->setHeaderLabels(array('name' => ucfirst(BL::lbl('Title')), 'url' => ''));
     // set url
     $this->dgUsage->setColumnURL('name', '[url]', ucfirst(BL::lbl('Edit')));
     // add use column
     $this->dgUsage->addColumn('edit', null, ucfirst(BL::lbl('Edit')), '[url]', BL::lbl('Edit'));
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:47,代码来源:edit.php

示例12: __construct

 public function __construct()
 {
     // store in reference so we can access it from everywhere
     Spoon::set('navigation', $this);
     // grab from the reference
     $this->URL = Spoon::get('url');
     // check if navigation cache file exists
     if (!SpoonFile::exists(BACKEND_CACHE_PATH . '/navigation/navigation.php')) {
         $this->buildCache();
     }
     $navigation = array();
     // require navigation-file
     require_once BACKEND_CACHE_PATH . '/navigation/navigation.php';
     // load it
     $this->navigation = (array) $navigation;
     // cleanup navigation (not needed for god user)
     if (!BackendAuthentication::getUser()->isGod()) {
         $this->navigation = $this->cleanup($this->navigation);
     }
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:20,代码来源:navigation.php

示例13: downloadCSV

 /**
  * Sets the headers so we may download the CSV file in question
  *
  * @param string $path The full path to the CSV file you wish to download.
  * @return array
  */
 private function downloadCSV($path)
 {
     // check if the file exists
     if (!SpoonFile::exists($path)) {
         throw new SpoonFileException('The file ' . $path . ' doesn\'t exist.');
     }
     // fetch the filename from the path string
     $explodedFilename = explode('/', $path);
     $filename = end($explodedFilename);
     // set headers for download
     $headers[] = 'Content-type: application/csv; charset=' . SPOON_CHARSET;
     $headers[] = 'Content-Disposition: attachment; filename="' . $filename . '"';
     $headers[] = 'Pragma: no-cache';
     // overwrite the headers
     SpoonHTTP::setHeaders($headers);
     // get the file contents
     $content = SpoonFile::getContent($path);
     // output the file contents
     echo $content;
     exit;
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:27,代码来源:addresses.php

示例14: __construct

 /**
  * The default constructor
  *
  * @return	void
  * @param	string $title			The title off the feed.
  * @param	string $link			The link of the feed.
  * @param	string $description		The description of the feed.
  * @param	array[optional] $items	An array with SpoonRSSItems.
  */
 public function __construct($title, $link, $description, array $items = array())
 {
     // decode
     $title = SpoonFilter::htmlspecialcharsDecode($title);
     $description = SpoonFilter::htmlspecialcharsDecode($description);
     // call the parent
     parent::__construct($title, FrontendModel::addURLParameters($link, array('utm_source' => 'feed', 'utm_medium' => 'rss', 'utm_campaign' => SpoonFilter::urlise($title))), $description, $items);
     // set feed properties
     $this->setLanguage(FRONTEND_LANGUAGE);
     $this->setCopyright(SpoonDate::getDate('Y') . ' ' . SpoonFilter::htmlspecialcharsDecode(FrontendModel::getModuleSetting('core', 'site_title_' . FRONTEND_LANGUAGE)));
     $this->setGenerator(SITE_RSS_GENERATOR);
     $this->setImage(SITE_URL . FRONTEND_CORE_URL . '/layout/images/rss_image.png', $title, $link);
     // theme was set
     if (FrontendModel::getModuleSetting('core', 'theme', null) != null) {
         // theme name
         $theme = FrontendModel::getModuleSetting('core', 'theme', null);
         // theme rss image exists
         if (SpoonFile::exists(PATH_WWW . '/frontend/themes/' . $theme . '/core/images/rss_image.png')) {
             // set rss image
             $this->setImage(SITE_URL . '/frontend/themes/' . $theme . '/core/images/rss_image.png', $title, $link);
         }
     }
 }
开发者ID:netconstructor,项目名称:forkcms,代码行数:32,代码来源:rss.php

示例15: execute

 /**
  * Execute the action
  */
 public function execute()
 {
     parent::execute();
     // add js
     $this->header->addJS('jstree/jquery.tree.js', null, false, false, false);
     $this->header->addJS('jstree/lib/jquery.cookie.js', null, false, false, false);
     $this->header->addJS('jstree/plugins/jquery.tree.cookie.js', null, false, false, false);
     // add css
     $this->header->addCSS('/backend/modules/pages/js/jstree/themes/fork/style.css', null, true);
     // check if the cached files exists
     if (!SpoonFile::exists(PATH_WWW . '/frontend/cache/navigation/keys_' . BackendLanguage::getWorkingLanguage() . '.php')) {
         BackendPagesModel::buildCache(BL::getWorkingLanguage());
     }
     if (!SpoonFile::exists(PATH_WWW . '/frontend/cache/navigation/navigation_' . BackendLanguage::getWorkingLanguage() . '.php')) {
         BackendPagesModel::buildCache(BL::getWorkingLanguage());
     }
     // load the dgRecentlyEdited
     $this->loadDataGrids();
     // parse
     $this->parse();
     // display the page
     $this->display();
 }
开发者ID:naujasdizainas,项目名称:forkcms,代码行数:26,代码来源:index.php


注:本文中的SpoonFile::exists方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。