當前位置: 首頁>>代碼示例>>PHP>>正文


PHP Inflector::slug方法代碼示例

本文整理匯總了PHP中Inflector::slug方法的典型用法代碼示例。如果您正苦於以下問題:PHP Inflector::slug方法的具體用法?PHP Inflector::slug怎麽用?PHP Inflector::slug使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Inflector的用法示例。


在下文中一共展示了Inflector::slug方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: init

 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $settings array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  */
 public function init($settings = array())
 {
     if (!class_exists('Memcache')) {
         return false;
     }
     if (!isset($settings['prefix'])) {
         $settings['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     $settings += array('engine' => 'Memcache', 'servers' => array('127.0.0.1'), 'compress' => false, 'persistent' => true);
     parent::init($settings);
     if ($this->settings['compress']) {
         $this->settings['compress'] = MEMCACHE_COMPRESSED;
     }
     if (is_string($this->settings['servers'])) {
         $this->settings['servers'] = array($this->settings['servers']);
     }
     if (!isset($this->_Memcache)) {
         $return = false;
         $this->_Memcache = new Memcache();
         foreach ($this->settings['servers'] as $server) {
             list($host, $port) = $this->_parseServerString($server);
             if ($this->_Memcache->addServer($host, $port, $this->settings['persistent'])) {
                 $return = true;
             }
         }
         return $return;
     }
     return true;
 }
開發者ID:4Queen,項目名稱:php-buildpack,代碼行數:38,代碼來源:MemcacheEngine.php

示例2: beforeSave

 public function beforeSave($options = array())
 {
     if (isset($this->data[$this->alias]['title'])) {
         $this->data[$this->alias]['slug'] = Inflector::slug($this->data[$this->alias]['title'], '-');
     }
     return true;
 }
開發者ID:JuLaurent,項目名稱:YouthBook.be,代碼行數:7,代碼來源:Book.php

示例3: season

function season($indoor)
{
    // The configuration settings values have "0" for the year, to facilitate form input
    $today = date('0-m-d');
    $today_wrap = date('1-m-d');
    // Build the list of applicable seasons
    $seasons = Configure::read('options.season');
    unset($seasons['None']);
    if (empty($seasons)) {
        return 'None';
    }
    foreach (array_keys($seasons) as $season) {
        $season_indoor = Configure::read("season_is_indoor.{$season}");
        if ($indoor != $season_indoor) {
            unset($seasons[$season]);
        }
    }
    // Create array of which season follows which
    $seasons = array_values($seasons);
    $seasons_shift = $seasons;
    array_push($seasons_shift, array_shift($seasons_shift));
    $next = array_combine($seasons, $seasons_shift);
    // Look for the season that has started without the next one starting
    foreach ($next as $a => $b) {
        $start = Configure::read('organization.' . Inflector::slug(low($a)) . '_start');
        $end = Configure::read('organization.' . Inflector::slug(low($b)) . '_start');
        // Check for a season that wraps past the end of the year
        if ($start > $end) {
            $end[0] = '1';
        }
        if ($today >= $start && $today < $end || $today_wrap >= $start && $today_wrap < $end) {
            return $a;
        }
    }
}
開發者ID:roboshed,項目名稱:Zuluru,代碼行數:35,代碼來源:zuluru.php

示例4: beforeDispatch

 /**
  * Checks whether the response was cached and set the body accordingly.
  *
  * @param CakeEvent $event containing the request and response object
  * @return CakeResponse with cached content if found, null otherwise
  */
 public function beforeDispatch(CakeEvent $event)
 {
     if (Configure::read('Cache.check') !== true) {
         return;
     }
     $path = $event->data['request']->here();
     if ($path === '/') {
         $path = 'home';
     }
     $prefix = Configure::read('Cache.viewPrefix');
     if ($prefix) {
         $path = $prefix . '_' . $path;
     }
     $path = strtolower(Inflector::slug($path));
     $filename = CACHE . 'views' . DS . $path . '.php';
     if (!file_exists($filename)) {
         $filename = CACHE . 'views' . DS . $path . '_index.php';
     }
     if (file_exists($filename)) {
         $controller = null;
         $view = new View($controller);
         $result = $view->renderCache($filename, microtime(true));
         if ($result !== false) {
             $event->stopPropagation();
             $event->data['response']->body($result);
             return $event->data['response'];
         }
     }
 }
開發者ID:ophilli,項目名稱:Inventory,代碼行數:35,代碼來源:CacheDispatcher.php

示例5: init

 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $setting array of setting for the engine
  * @return boolean True if the engine has been successfully initialized, false if not
  * @access public
  */
 function init($settings = array())
 {
     if (!class_exists('Memcache')) {
         return false;
     }
     parent::init(array_merge(array('engine' => 'Memcache', 'prefix' => Inflector::slug(APP_DIR) . '_', 'servers' => array('127.0.0.1'), 'compress' => false), $settings));
     if ($this->settings['compress']) {
         $this->settings['compress'] = MEMCACHE_COMPRESSED;
     }
     if (!is_array($this->settings['servers'])) {
         $this->settings['servers'] = array($this->settings['servers']);
     }
     if (!isset($this->__Memcache)) {
         $return = false;
         $this->__Memcache =& new Memcache();
         foreach ($this->settings['servers'] as $server) {
             $parts = explode(':', $server);
             $host = $parts[0];
             $port = 11211;
             if (isset($parts[1])) {
                 $port = $parts[1];
             }
             if ($this->__Memcache->addServer($host, $port)) {
                 $return = true;
             }
         }
         return $return;
     }
     return true;
 }
開發者ID:maverick2041,項目名稱:wpkgexpress,代碼行數:40,代碼來源:memcache.php

示例6: beforeSave

 public function beforeSave($options = array())
 {
     if (empty($this->data['ProductCategory']['slug']) && isset($this->data['ProductCategory']['slug']) && !empty($this->data['ProductCategory']['name'])) {
         $this->data['ProductCategory']['slug'] = strtolower(Inflector::slug($this->data['ProductCategory']['name'], '-'));
     }
     return true;
 }
開發者ID:AntoineCuny,項目名稱:VinylStore,代碼行數:7,代碼來源:ProductCategory.php

示例7: init

 /**
  * Initialize the Cache Engine
  *
  * Called automatically by the cache frontend
  * To reinitialize the settings call Cache::engine('EngineName', [optional] settings = array());
  *
  * @param array $settings array of setting for the engine
  * @return bool True if the engine has been successfully initialized, false if not
  */
 public function init($settings = [])
 {
     if (!class_exists('Memcached')) {
         return false;
     }
     if (!isset($settings['prefix'])) {
         $settings['prefix'] = Inflector::slug(APP_DIR) . '_';
     }
     $settings += ['engine' => 'Memcached', 'servers' => ['127.0.0.1'], 'compress' => false, 'persistent' => true];
     parent::init($settings);
     $this->_keys .= $this->settings['prefix'];
     if (!is_array($this->settings['servers'])) {
         $this->settings['servers'] = [$this->settings['servers']];
     }
     if (!isset($this->_Memcached)) {
         $return = false;
         $this->_Memcached = new Memcached($this->settings['persistent'] ? 'mc' : null);
         $this->_setOptions();
         if (!count($this->_Memcached->getServerList())) {
             $servers = [];
             foreach ($this->settings['servers'] as $server) {
                 $servers[] = $this->_parseServerString($server);
             }
             if ($this->_Memcached->addServers($servers)) {
                 $return = true;
             }
         }
         if (!$this->_Memcached->get($this->_keys)) {
             $this->_Memcached->set($this->_keys, '');
         }
         return $return;
     }
     return true;
 }
開發者ID:ByMyHandsOnly,項目名稱:BMHO_Web,代碼行數:43,代碼來源:MemcachedEngine.php

示例8: factoryActions

 public function factoryActions($action, $data)
 {
     switch ($action) {
         case 'create':
             // Get the current FactSite we are working on
             $FactSite = ClassRegistry::init('SiteFactory.FactSite');
             $FactSite->recursive = -1;
             $site = $FactSite->findById($data['FactSection']['fact_site_id']);
             // Get an available ID
             $CorkCorktile = ClassRegistry::init('Corktile.CorkCorktile');
             $data['FactSection']['metadata']['corktile_key'] = $CorkCorktile->getAvailableUuid();
             // Create the corktile
             $config = array('key' => $data['FactSection']['metadata']['corktile_key'], 'type' => 'cs_cork', 'location' => array('public_page', 'fact_sites', $site['FactSite']['mexc_space_id'], $data['FactSection']['metadata']['address']), 'title' => sprintf(__d('mexc_contacts', 'Texto da página \'%s\' do programa \'%s\'', true), $data['FactSection']['name'], $site['FactSite']['name']), 'editorsRecommendations' => __d('fact_site', 'O conteúdo da página pode ser editado aqui.', true), 'options' => array('type' => 'fact_site_static', 'cs_type' => 'fact_site_static'));
             if ($CorkCorktile->getData($config) == false) {
                 return false;
             }
             return $data;
             break;
         case 'save':
             if (empty($data['FactSection']['metadata']['address'])) {
                 $data['FactSection']['metadata']['address'] = $data['FactSection']['name'];
             }
             $data['FactSection']['metadata']['address'] = strtolower(Inflector::slug($data['FactSection']['metadata']['address']));
             return $data;
             break;
         case 'delete':
             if (!empty($data['FactSection']['metadata']['corktile_key'])) {
                 $CorkCorktile = ClassRegistry::init('Corktile.CorkCorktile');
                 return $CorkCorktile->delete($data['FactSection']['metadata']['corktile_key']);
             }
             break;
     }
     return true;
 }
開發者ID:hugomelo,項目名稱:mexc_static_pages,代碼行數:34,代碼來源:mexc_static_page.php

示例9: beforeSave

 public function beforeSave($options = array())
 {
     if (empty($this->data['Rol']['machin_name'])) {
         $this->data['Rol']['machin_name'] = strtolower(Inflector::slug($this->data['Rol']['name']));
     }
     return true;
 }
開發者ID:ristorantino,項目名稱:users,代碼行數:7,代碼來源:Rol.php

示例10: cached

	function cached($url) {
		if (Configure::read('Cache.check') === true) {
			$path = $this->here;
			if ($this->here == '/') {
				$path = 'home';
			}
			if($this->Session->check('Auth.User._id')){
				//$path = $_SESSION['Auth']['User']['_id'].'_'.strtolower(Inflector::slug($path));
				$path = '4d33940fda220a9606000003_'.strtolower(Inflector::slug($path));
			}else{
				$path = strtolower(Inflector::slug($path));
			}

			$filename = CACHE . 'views' . DS . $path . '.php';

			if (!file_exists($filename)) {
				$filename = CACHE . 'views' . DS . $path . '_index.php';
			}

			if (file_exists($filename)) {
				if (!class_exists('View')) {
					App::import('View', 'View', false);
				}
				$controller = null;
				$view =& new View($controller);
				$return = $view->renderCache($filename, getMicrotime());
				if (!$return) {
					ClassRegistry::removeObject('view');
				}
				return $return;
			}
		}
		return false;
	}
開發者ID:ninetwentyfour,項目名稱:Homkora,代碼行數:34,代碼來源:my_dispatcher.php

示例11: beforeSave

 public function beforeSave($options = array())
 {
     $result = parent::beforeSave($options);
     $slug = Inflector::slug($this->data['Page']['title']);
     $this->data['Page']['slug'] = $slug;
     return $result;
 }
開發者ID:predominant,項目名稱:phpmatsuri-cms,代碼行數:7,代碼來源:page.php

示例12: _prepareToWriteFiles

 function _prepareToWriteFiles(&$model, $field)
 {
     $this->toWrite[$field] = $model->data[$model->name][$field];
     // make filename URL friendly by using Cake's Inflector
     $this->toWrite[$field]['name'] = Inflector::slug(substr($this->toWrite[$field]['name'], 0, strrpos($this->toWrite[$field]['name'], '.'))) . substr($this->toWrite[$field]['name'], strrpos($this->toWrite[$field]['name'], '.'));
     // extension
 }
開發者ID:hipposdigital,項目名稱:uploadpack,代碼行數:7,代碼來源:upload.php

示例13: urlByKey

 /**
  * Form the access url by key
  *
  * @param string $key
  * @return string Url (absolute)
  */
 public static function urlByKey($key, $title = null, $slugTitle = true)
 {
     if ($title && $slugTitle) {
         $title = Inflector::slug($title, '-');
     }
     return Router::url(array('admin' => false, 'plugin' => 'tools', 'controller' => 'qurls', 'action' => 'go', $key, $title), true);
 }
開發者ID:Jony01,項目名稱:LLD,代碼行數:13,代碼來源:Qurl.php

示例14: newName

 function newName($folder, $fileName)
 {
     //elimino gli spazi bianchi
     //$fileName = str_replace(' ', '_', $fileName);
     $fileParts = explode('.', $fileName);
     foreach ($fileParts as $n => $filePart) {
         $fileParts[$n] = Inflector::slug($filePart);
     }
     $fileName = implode('.', $fileParts);
     if (preg_match('/([0-9]+)([.][a-zA-Z0-9]{3,})$/', $fileName, $matches)) {
         //il file è numerato (nome123.ext)
         $fileName = preg_replace('/' . $matches[count($matches) - 2] . '/', (int) $matches[count($matches) - 2] + 1, $fileName);
     } else {
         //il file non è numerato (nome.ext): lo numero io
         $matches = explode('.', $fileName);
         $matches[count($matches) - 2] .= '1';
         $fileName = implode('.', $matches);
     }
     //controllo ricorsivo -> serve per assicurarsi di non sovrascrivere altri files
     if (is_file($folder . $fileName)) {
         return $this->newName($folder, $fileName);
     } else {
         return $fileName;
     }
 }
開發者ID:amerlini,項目名稱:digigas-from-hg,代碼行數:25,代碼來源:files.php

示例15: init

	/**
	 * Initialize the cache engine
	 *
	 * Called automatically by the cache frontend
	 *
	 * @param array $params Associative array of parameters for the engine
	 * @return boolean true if the engine has been succesfully initialized, false if not
	 * @access public
	 */
	function init($settings = array()) {
		if (!function_exists('eaccelerator_put')) {
			return false;
		}
          return parent::init(array_merge(array('engine' => 'Eaccelerator', 'prefix' => Inflector::slug(APP_DIR) . '_'), $settings));

	}
開發者ID:nard,項目名稱:Pushchat-Server,代碼行數:16,代碼來源:eaccelerator.php


注:本文中的Inflector::slug方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。