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


PHP StringUtil::right方法代码示例

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


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

示例1: validate

 function validate(Zikula_Form_View $view)
 {
     parent::validate($view);
     if (!$this->isValid) {
         return;
     }
     if ($this->text != '') {
         if (!is_dir($this->text) || !is_readable($this->text)) {
             $this->setError(__f('The path %s does not exist or is not readable by the webserver.', $this->text));
         } elseif ($this->writable == true && !is_writable($this->text)) {
             $this->setError(__f('The webserver cannot write to %s.', $this->text));
         } else {
             if ($this->removeSlash == true) {
                 do {
                     $hasSlash = false;
                     if (StringUtil::right($this->text, 1) == '/') {
                         $hasSlash = true;
                         $this->text = StringUtil::left($this->text, strlen($this->text) - 1);
                     }
                 } while ($hasSlash == true);
             }
         }
     } else {
         $this->setError(__('Error! Missing path.'));
     }
 }
开发者ID:robbrandt,项目名称:Avatar,代码行数:26,代码来源:PathInput.php

示例2: update

 /**
  * Update item
  *
  * Takes info from edit form and passes to API
  * @author The Zikula Development Team
  * @param 'eid' Ephemeride id to delete
  * @param 'qauther' Author of item to delete
  * @param 'confirm' Delete confirmation
  * @return mixed HTML string if confirm is null, true otherwise
  */
 public function update($args)
 {
     // Confirm the forms authorisation key
     $this->checkCsrfToken();
     // get parameters from whatever input we need.
     $ephemerid = FormUtil::getPassedValue('ephemerid', isset($args['ephemerid']) ? $args['ephemerid'] : null, 'POST');
     $delcache = FormUtil::getPassedValue('delcache', isset($args['delcache']) ? $args['delcache'] : null, 'POST');
     // check to see if we have been passed $objectid, the generic item identifier.
     if (!empty($ephemerid['objectid'])) {
         $ephemerid['eid'] = $ephemerid['objectid'];
     }
     // add date names as in table
     $ephemerid['did'] = $ephemerid['Date_Day'];
     $ephemerid['mid'] = $ephemerid['Date_Month'];
     $ephemerid['yid'] = $ephemerid['Date_Year'];
     // notable by its absence there is no security check here.
     // update the ephemerid
     if (ModUtil::apiFunc($this->name, 'admin', 'update', $ephemerid)) {
         // success
         LogUtil::registerStatus($this->__('Done! Ephemeride updated.'));
         if ($delcache) {
             // delete respective block cache
             $cachedir = System::getVar('temp');
             if (StringUtil::right($cachedir, 1) != '/') {
                 $cachedir .= '/';
             }
             $cachedir .= ModUtil::getVar($this->name, 'cache_dir', 'any_cache');
             // delete all files matching a pattern
             array_map('unlink', glob($cachedir . '/ephem_*'));
         }
     }
     // this function generated no output, and so now it is complete we redirect
     // the user to an appropriate page for them to carry on their work
     return System::redirect(ModUtil::url($this->name, 'admin', 'view'));
 }
开发者ID:nmpetkov,项目名称:Ephemerides,代码行数:45,代码来源:Admin.php

示例3: display

 /**
  * display block
  * @author       The Zikula Development Team
  */
 public function display($blockinfo)
 {
     // security check
     if (!SecurityUtil::checkPermission('Ephemerides:Ephemerideblock:', $blockinfo['bid'] . '::', ACCESS_READ)) {
         return;
     }
     // Get current content
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     if (!isset($vars['category'])) {
         $vars['category'] = null;
     }
     // Implementation cached content: @nikp
     $enable_cache = true;
     $write_to_cache = false;
     # flag
     $cache_time = 3600;
     # seconds
     if (isset($vars['cache_time'])) {
         $cache_time = $vars['cache_time'];
     }
     $content = "";
     $title = $blockinfo['title'];
     if ($enable_cache and $cache_time > 0) {
         $cachefilestem = 'ephem_' . $blockinfo['bid'];
         $cachedir = System::getVar('temp');
         if (StringUtil::right($cachedir, 1) != '/') {
             $cachedir .= '/';
         }
         if (isset($vars['cache_dir']) and !empty($vars['cache_dir'])) {
             $cachedir .= $vars['cache_dir'];
         } else {
             $cachedir .= 'any_cache';
         }
         $cachefile = $cachedir . '/' . $cachefilestem . '_' . SecurityUtil::getSecurityLevel(SecurityUtil::getAuthInfo(), 'Ephemerides::', '::');
         $cachefile_title = $cachedir . '/' . $cachefilestem . '_t';
         // attempt to load from cache
         if (file_exists($cachefile)) {
             $file_time = filectime($cachefile);
             $now = time();
             $diff = $now - $file_time;
             if ($diff <= $cache_time) {
                 $content = file_get_contents($cachefile);
             }
             if (file_exists($cachefile_title)) {
                 $title = file_get_contents($cachefile_title);
             }
         }
         if (empty($content)) {
             $write_to_cache = true;
         }
         # not loaded, flag to write to cache later
     }
     if (empty($content)) {
         // Create output object
         $this->view->setCaching(false);
         // we implement caching other way
         $apiargs = array();
         $apiargs['status'] = 1;
         // Make a category filter only if categorization is enabled
         $enablecategorization = ModUtil::getVar($this->name, 'enablecategorization');
         if ($enablecategorization) {
             // load the categories system
             if (!Loader::loadClass('CategoryRegistryUtil')) {
                 return LogUtil::registerError(__f('Error! Could not load [%s] class.'), 'CategoryRegistryUtil');
             }
             // Get the registrered categories for the module
             $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories($this->name, 'ephem');
             $this->view->assign('catregistry', $catregistry);
             $apiargs['catregistry'] = $catregistry;
             $apiargs['category'] = $vars['category'];
         }
         $this->view->assign('enablecategorization', $enablecategorization);
         $this->view->assign($vars);
         // assign the block vars
         if (!isset($vars['category']) || !is_array($vars['category'])) {
             $vars['category'] = array();
         }
         $this->view->assign('category', $vars['category']);
         // get items
         $items = ModUtil::apiFunc($this->name, 'user', 'gettoday', $apiargs);
         if (!$items) {
             return '';
             # do not display empty block: @nikp
         }
         $this->view->assign('items', $items);
         // Populate block info and pass to theme
         $content = $this->view->fetch('ephemerides_block_ephemeride.tpl');
         // loop to see if we have items of type=1 (events), if not - not to put title to the block (holidays only)
         $have_events = false;
         foreach ($items as $item) {
             if ($item['type'] == 1) {
                 $have_events = true;
                 break;
             }
         }
         if (!$have_events) {
//.........这里部分代码省略.........
开发者ID:nmpetkov,项目名称:Ephemerides,代码行数:101,代码来源:Ephemeride.php

示例4: display

 /**
  * display block
  * @author       The Zikula Development Team
  */
 public function display($blockinfo)
 {
     // security check
     if (!SecurityUtil::checkPermission('Quotes:Quoteblock:', $blockinfo['bid'] . '::', ACCESS_READ)) {
         return;
     }
     // Get current content
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // filter desplay by hour of the day: @nikp
     $a_datetime = getdate();
     if (isset($vars['hourfrom']) and $vars['hourfrom'] > -1 and $a_datetime["hours"] < $vars['hourfrom']) {
         return "";
     }
     if (isset($vars['hourto']) and $vars['hourto'] > -1 and $a_datetime["hours"] > $vars['hourto']) {
         return "";
     }
     if (isset($vars['wdayfrom']) and $vars['wdayfrom'] > -1 and $a_datetime["wday"] < $vars['wdayfrom']) {
         return "";
     }
     if (isset($vars['wdayto']) and $vars['wdayto'] > -1 and $a_datetime["wday"] > $vars['wdayto']) {
         return "";
     }
     if (isset($vars['mdayfrom']) and $vars['mdayfrom'] > -1 and $a_datetime["mday"] < $vars['mdayfrom']) {
         return "";
     }
     if (isset($vars['mdayto']) and $vars['mdayto'] > -1 and $a_datetime["mday"] > $vars['mdayto']) {
         return "";
     }
     if (isset($vars['monfrom']) and $vars['monfrom'] > -1 and $a_datetime["mon"] < $vars['monfrom']) {
         return "";
     }
     if (isset($vars['monto']) and $vars['monto'] > -1 and $a_datetime["mon"] > $vars['monto']) {
         return "";
     }
     if (!isset($vars['category'])) {
         $vars['category'] = null;
     }
     if (isset($vars['ballooncolor'])) {
         $ballooncolor = $vars['ballooncolor'];
     } else {
         $ballooncolor = "grey";
     }
     // Implementation cached content: @nikp
     $enable_cache = true;
     $write_to_cache = false;
     # flag
     $cache_time = 240;
     # seconds
     if (isset($vars['cache_time'])) {
         $cache_time = $vars['cache_time'];
     }
     $content = "";
     if ($enable_cache and $cache_time > 0) {
         $cachefilestem = 'quote_' . $blockinfo['bid'];
         $cachedir = System::getVar('temp');
         if (StringUtil::right($cachedir, 1) != '/') {
             $cachedir .= '/';
         }
         if (isset($vars['cache_dir']) and !empty($vars['cache_dir'])) {
             $cachedir .= $vars['cache_dir'];
         } else {
             $cachedir .= 'any_cache';
         }
         $cachefile = $cachedir . '/' . $cachefilestem . '_' . SecurityUtil::getSecurityLevel(SecurityUtil::getAuthInfo(), 'Quotes::', '::');
         // attempt to load from cache
         if (file_exists($cachefile)) {
             $file_time = filectime($cachefile);
             $now = time();
             $diff = $now - $file_time;
             if ($diff <= $cache_time) {
                 $content = file_get_contents($cachefile);
             }
         }
         if (empty($content)) {
             $write_to_cache = true;
             # not loaded, flag to write to cache later
         }
     }
     if (empty($content)) {
         // Create output object
         $this->view->setCaching(false);
         // we implement caching other way
         mt_srand((double) microtime() * 1000000);
         $apiargs = array();
         $apiargs['status'] = 1;
         // Make a category filter only if categorization is enabled
         $enablecategorization = ModUtil::getVar($this->name, 'enablecategorization');
         if ($enablecategorization) {
             // load the categories system
             if (!Loader::loadClass('CategoryRegistryUtil')) {
                 return LogUtil::registerError(__f('Error! Could not load [%s] class.'), 'CategoryRegistryUtil');
             }
             // Get the registrered categories for the module
             $catregistry = CategoryRegistryUtil::getRegisteredModuleCategories($this->name, 'quotes');
             $this->view->assign('catregistry', $catregistry);
             $apiargs['catregistry'] = $catregistry;
//.........这里部分代码省略.........
开发者ID:nmpetkov,项目名称:Quotes,代码行数:101,代码来源:Quote.php

示例5: display

 /**
  * Display block
  */
 public function display($blockinfo)
 {
     if (!SecurityUtil::checkPermission('ZphpBB2_Lastposts::', $blockinfo[bid] . "::", ACCESS_READ)) {
         return;
     }
     if (!ModUtil::available('ZphpBB2')) {
         return;
     }
     // Get variables from content block
     $vars = BlockUtil::varsFromContent($blockinfo['content']);
     // Implementation cached content
     $enable_cache = true;
     $write_to_cache = false;
     # flag
     $cache_time = 180;
     # seconds
     if (isset($vars['cache_time'])) {
         $cache_time = $vars['cache_time'];
     }
     $content = "";
     if ($enable_cache and $cache_time > 0) {
         $cachefilestem = 'ZphpBB2_' . $blockinfo['bid'];
         $cachedir = System::getVar('temp');
         if (StringUtil::right($cachedir, 1) != '/') {
             $cachedir .= '/';
         }
         if (isset($vars['cache_dir']) and !empty($vars['cache_dir'])) {
             $cachedir .= $vars['cache_dir'];
         } else {
             $cachedir .= 'any_cache';
         }
         $cachefile = $cachedir . '/' . $cachefilestem;
         // attempt to load from cache
         if (file_exists($cachefile)) {
             $file_time = filectime($cachefile);
             $now = time();
             $diff = $now - $file_time;
             if ($diff <= $cache_time) {
                 $content = file_get_contents($cachefile);
             }
         }
         if (empty($content)) {
             $write_to_cache = true;
         }
         # not loaded, flag to write to cache later
     }
     if (empty($content)) {
         // Create output object
         $connection = Doctrine_Manager::getInstance()->getCurrentConnection();
         $table_prefix = ModUtil::getVar('ZphpBB2', 'table_prefix', 'phpbb_');
         // include some files
         define('IN_PHPBB', true);
         $phpbb_root_path = 'modules/ZphpBB2/vendor/phpBB2/';
         include_once $phpbb_root_path . "includes/constants.php";
         $blockinfo['content'] = "";
         // Defaults some things if they are empty!
         $vars['last_X_posts'] = $vars['last_X_posts'] ? $vars['last_X_posts'] : "5";
         //do we want every topic to appear just once?
         $connkeys = $vars['group_topics'] ? "" . TOPICS_TABLE . ".topic_last_post_id = " . POSTS_TABLE . ".post_id" : "" . TOPICS_TABLE . ".topic_id = " . POSTS_TABLE . ".topic_id";
         //limit to certain forums?
         if (!is_null($vars['excluded_forums']) && is_array($vars['excluded_forums'])) {
             $excluded_forums = in_array("", $vars['excluded_forums']) ? "" : "AND " . FORUMS_TABLE . ".forum_id NOT IN (" . implode(", ", $vars['excluded_forums']) . ")";
         }
         $lastvisit = 0;
         //list of forums user can see if private
         $viewforums = "";
         //list of forums user can look into if private
         $readforums = "";
         //list of forums where user is moderator
         $modforums = "";
         //just for guests
         $userstate = 0;
         if (UserUtil::isLoggedIn()) {
             $uid = UserUtil::getVar('uid');
             //permission level for registered users
             $userstate = AUTH_REG;
             //are you an board admin?
             $query = "SELECT user_level, user_lastvisit FROM   " . USERS_TABLE . " WHERE  user_id = {$uid}";
             $stmt = $connection->prepare($query);
             $stmt->execute();
             $result = $stmt->fetchAll(Doctrine_Core::FETCH_ASSOC);
             list($level, $lastvisit) = $result[0];
             if ($level == ADMIN) {
                 //user have complete access
                 $userstate = AUTH_ADMIN;
             } else {
                 $query = "SELECT " . AUTH_ACCESS_TABLE . ".forum_id,\n                        max(" . AUTH_ACCESS_TABLE . ".auth_view), \n                        max(" . AUTH_ACCESS_TABLE . ".auth_read), \n                        max(" . AUTH_ACCESS_TABLE . ".auth_mod)\n                        FROM   " . USER_GROUP_TABLE . " INNER JOIN " . AUTH_ACCESS_TABLE . " ON " . USER_GROUP_TABLE . ".group_id = " . AUTH_ACCESS_TABLE . ".group_id\n                        WHERE  " . USER_GROUP_TABLE . ".user_id = {$uid}\n                        GROUP BY " . AUTH_ACCESS_TABLE . ".forum_id";
                 $stmt = $connection->prepare($query);
                 $stmt->execute();
                 $result = $stmt->fetchAll(Doctrine_Core::FETCH_ASSOC);
                 foreach ($result as $r) {
                     list($forum_id, $auth_view, $auth_read, $auth_mod) = $r;
                     //let's make a nice list of forums the user is allowed to view, read and moderate
                     if ($auth_read | $auth_mod) {
                         $readforums .= empty($readforums) ? $forum_id : ", " . $forum_id;
                     }
                     if ($auth_view | $auth_mod) {
//.........这里部分代码省略.........
开发者ID:nmpetkov,项目名称:ZphpBB2,代码行数:101,代码来源:Lastposts.php


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