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


PHP StringEndsWith函数代码示例

本文整理汇总了PHP中StringEndsWith函数的典型用法代码示例。如果您正苦于以下问题:PHP StringEndsWith函数的具体用法?PHP StringEndsWith怎么用?PHP StringEndsWith使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: OrderBy

 /** Set the order of the comments. */
 public function OrderBy($Value = NULL)
 {
     if ($Value === NULL) {
         return $this->_OrderBy;
     }
     if (is_string($Value)) {
         $Value = array($Value);
     }
     if (is_array($Value)) {
         // Set the order of this object.
         $OrderBy = array();
         foreach ($Value as $Part) {
             if (StringEndsWith($Part, ' desc', TRUE)) {
                 $OrderBy[] = array(substr($Part, 0, -5), 'desc');
             } elseif (StringEndsWith($Part, ' asc', TRUE)) {
                 $OrderBy[] = array(substr($Part, 0, -4), 'asc');
             } else {
                 $OrderBy[] = array($Part, 'asc');
             }
         }
         $this->_OrderBy = $OrderBy;
     } elseif (is_a($Value, 'Gdn_SQLDriver')) {
         // Set the order of the given sql.
         foreach ($this->_OrderBy as $Parts) {
             $Value->OrderBy($Parts[0], $Parts[1]);
         }
     }
 }
开发者ID:TiGR,项目名称:Garden,代码行数:29,代码来源:class.commentmodel.php

示例2: GetTextRowsFromText

function GetTextRowsFromText($fontSize, $font, $text, $maxWidth)
{
    $text = str_replace("\n", "\n ", $text);
    $text = str_replace("\\n", "\n ", $text);
    $words = explode(" ", $text);
    $rows = array();
    $tmpRow = "";
    for ($i = 0; $i < count($words); $i++) {
        //last word
        if ($i == count($words) - 1) {
            $rows[] = $tmpRow . $words[$i];
            break;
        }
        if (GetTextWidth($fontSize, $font, $tmpRow . $words[$i]) > $maxWidth) {
            $rows[] = $tmpRow;
            $tmpRow = "";
        } else {
            if (StringEndsWith($tmpRow, "\n ")) {
                $tmpRow = str_replace("\n ", "", $tmpRow);
                $rows[] = $tmpRow;
                $tmpRow = "";
            }
        }
        //add new word to row
        $tmpRow .= $words[$i] . " ";
    }
    return $rows;
}
开发者ID:faizanvahevaria,项目名称:Quote-Generator-PHP,代码行数:28,代码来源:createimage.php

示例3: Analytics

 public function Analytics($Method, $RequestParameters, $Callback = FALSE)
 {
     $AnalyticsServer = C('Garden.Analytics.Remote', 'http://analytics.vanillaforums.com');
     $FullMethod = explode('/', $Method);
     if (sizeof($FullMethod) < 2) {
         array_unshift($FullMethod, "analytics");
     }
     list($ApiController, $ApiMethod) = $FullMethod;
     $ApiController = strtolower($ApiController);
     $ApiMethod = StringEndsWith(strtolower($ApiMethod), '.json', TRUE, TRUE) . '.json';
     $FinalURL = CombinePaths(array($AnalyticsServer, $ApiController, $ApiMethod));
     // Sign request
     $this->Sign($RequestParameters, TRUE);
     $FinalURL .= '?' . http_build_query($RequestParameters);
     try {
         $Response = ProxyRequest($FinalURL, 10, TRUE);
     } catch (Exception $e) {
         $Response = FALSE;
     }
     if ($Response !== FALSE) {
         $JsonResponse = json_decode($Response);
         if ($JsonResponse !== FALSE) {
             $JsonResponse = (array) GetValue('Analytics', $JsonResponse, FALSE);
         }
         // If we received a reply, parse it
         if ($JsonResponse !== FALSE) {
             $this->ParseAnalyticsResponse($JsonResponse, $Response, $Callback);
             return $JsonResponse;
         }
     }
     return FALSE;
 }
开发者ID:Raz0r,项目名称:Garden,代码行数:32,代码来源:class.statistics.php

示例4: Render

   /**
    * Render the given view.
    *
    * @param string $Path The path to the view's file.
    * @param Controller $Controller The controller that is rendering the view.
    */
   public function Render($Path, $Controller) {
      $Smarty = $this->Smarty();

      // Get a friendly name for the controller.
      $ControllerName = get_class($Controller);
      if (StringEndsWith($ControllerName, 'Controller', TRUE)) {
         $ControllerName = substr($ControllerName, 0, -10);
      }

      // Get an ID for the body.
      $BodyIdentifier = strtolower($Controller->ApplicationFolder.'_'.$ControllerName.'_'.Gdn_Format::AlphaNumeric(strtolower($Controller->RequestMethod)));
      $Smarty->assign('BodyID', $BodyIdentifier);
      //$Smarty->assign('Config', Gdn::Config());

      // Assign some information about the user.
      $Session = Gdn::Session();
      if($Session->IsValid()) {
         $User = array(
            'Name' => $Session->User->Name,
            'CountNotifications' => (int)GetValue('CountNotifications', $Session->User->CountNotifications, 0),
            'CountUnreadConversations' => (int)GetValue('CountUnreadConversations', $Session->User, 0),
            'SignedIn' => TRUE);
      } else {
         $User = FALSE; /*array(
            'Name' => '',
            'CountNotifications' => 0,
            'SignedIn' => FALSE);*/
      }
      $Smarty->assign('User', $User);

      // Make sure that any datasets use arrays instead of objects.
      foreach($Controller->Data as $Key => $Value) {
         if($Value instanceof Gdn_DataSet) {
            $Controller->Data[$Key] = $Value->ResultArray();
         } elseif($Value instanceof stdClass) {
            $Controller->Data[$Key] = (array)$Value;
         }
      }
     
      $Controller->Data['BodyClass'] = GetValue('CssClass', $Controller->Data, '', TRUE);

      $Smarty->assign('Assets', (array)$Controller->Assets);
      $Smarty->assign('Path', Gdn::Request()->Path());

      // Assigign the controller data last so the controllers override any default data.
      $Smarty->assign($Controller->Data);

      $Smarty->Controller = $Controller; // for smarty plugins
      $Smarty->security = TRUE;
      $Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'],
         array('CheckPermission', 'GetValue', 'SetValue', 'Url'));
      $Smarty->secure_dir = array($Path);
      $Smarty->display($Path);
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:60,代码来源:class.smarty.php

示例5: Analytics

 public function Analytics($Method, $RequestParameters, $Callback = FALSE, $ParseResponse = TRUE)
 {
     $FullMethod = explode('/', $Method);
     if (sizeof($FullMethod) < 2) {
         array_unshift($FullMethod, "analytics");
     }
     list($ApiController, $ApiMethod) = $FullMethod;
     $ApiController = strtolower($ApiController);
     $ApiMethod = StringEndsWith(strtolower($ApiMethod), '.json', TRUE, TRUE) . '.json';
     $FinalURL = 'http://' . CombinePaths(array($this->AnalyticsServer, $ApiController, $ApiMethod));
     // Allow hooking of analytics events
     $this->EventArguments['AnalyticsMethod'] =& $Method;
     $this->EventArguments['AnalyticsArgs'] =& $RequestParameters;
     $this->EventArguments['AnalyticsUrl'] =& $FinalURL;
     $this->FireEvent('SendAnalytics');
     // Sign request
     $this->Sign($RequestParameters, TRUE);
     $RequestMethod = GetValue('RequestMethod', $RequestParameters, 'GET');
     unset($RequestParameters['RequestMethod']);
     try {
         $ProxyRequest = new ProxyRequest(FALSE, array('Method' => $RequestMethod, 'Timeout' => 10, 'Cookies' => FALSE));
         $Response = $ProxyRequest->Request(array('Url' => $FinalURL), $RequestParameters);
     } catch (Exception $e) {
         $Response = FALSE;
     }
     if ($Response !== FALSE) {
         $JsonResponse = json_decode($Response, TRUE);
         if ($JsonResponse !== FALSE) {
             if ($ParseResponse) {
                 $AnalyticsJsonResponse = (array) GetValue('Analytics', $JsonResponse, FALSE);
                 // If we received a reply, parse it
                 if ($AnalyticsJsonResponse !== FALSE) {
                     $this->ParseAnalyticsResponse($AnalyticsJsonResponse, $Response, $Callback);
                     return $AnalyticsJsonResponse;
                 }
             } else {
                 return $JsonResponse;
             }
         }
         return $Response;
     }
     return FALSE;
 }
开发者ID:rnovino,项目名称:Garden,代码行数:43,代码来源:class.statistics.php

示例6: Query

 public function Query($Sql, $InputParameters = NULL, $Options = array())
 {
     $Trace = debug_backtrace();
     $Method = '';
     foreach ($Trace as $Info) {
         $Class = GetValue('class', $Info, '');
         if ($Class === '' || StringEndsWith($Class, 'Model', TRUE) || StringEndsWith($Class, 'Plugin', TRUE)) {
             $Type = ArrayValue('type', $Info, '');
             $Method = $Class . $Type . $Info['function'] . '(' . self::FormatArgs($Info['args']) . ')';
             break;
         }
     }
     // Save the query for debugging
     // echo '<br />adding to queries: '.$Sql;
     $Query = array('Sql' => $Sql, 'Parameters' => $InputParameters, 'Method' => $Method);
     $SaveQuery = TRUE;
     if (isset($Options['Cache'])) {
         $CacheKeys = (array) $Options['Cache'];
         $Cache = array();
         $AllSet = TRUE;
         foreach ($CacheKeys as $CacheKey) {
             $Value = Gdn::Cache()->Get($CacheKey);
             $CacheValue = $Value !== Gdn_Cache::CACHEOP_FAILURE;
             $AllSet &= $CacheValue;
             $Cache[$CacheKey] = $CacheValue;
         }
         $SaveQuery = !$AllSet;
         $Query['Cache'] = $Cache;
     }
     // Start the Query Timer
     $TimeStart = Now();
     $Result = parent::Query($Sql, $InputParameters, $Options);
     $Query = array_merge($this->LastInfo, $Query);
     // Aggregate the query times
     $TimeEnd = Now();
     $this->_ExecutionTime += $TimeEnd - $TimeStart;
     if ($SaveQuery && !StringBeginsWith($Sql, 'set names')) {
         $Query['Time'] = $TimeEnd - $TimeStart;
         $this->_Queries[] = $Query;
     }
     return $Result;
 }
开发者ID:edward-tsai,项目名称:vanilla4china,代码行数:42,代码来源:class.databasedebug.php

示例7: Query

 /**
  * @todo Put the query debugging logic into the debug plugin.
  * 1. Create a subclass of this object where Query() does the debugging stuff.
  * 2. Install that class to Gdn to override the database.
  */
 public function Query($Sql, $InputParameters = NULL)
 {
     $Trace = debug_backtrace();
     $Method = '';
     foreach ($Trace as $Info) {
         $Class = GetValue('class', $Info, '');
         if ($Class === '' || StringEndsWith($Class, 'Model', TRUE)) {
             $Type = ArrayValue('type', $Info, '');
             $Method = $Class . $Type . $Info['function'] . '(' . self::FormatArgs($Info['args']) . ')';
             break;
         }
     }
     // Save the query for debugging
     // echo '<br />adding to queries: '.$Sql;
     $this->_Queries[] = array('Sql' => $Sql, 'Parameters' => $InputParameters, 'Method' => $Method);
     // Start the Query Timer
     $TimeStart = list($sm, $ss) = explode(' ', microtime());
     $Result = parent::Query($Sql, $InputParameters);
     // Aggregate the query times
     $TimeEnd = list($em, $es) = explode(' ', microtime());
     $this->_ExecutionTime += $em + $es - ($sm + $ss);
     $this->_QueryTimes[] = $em + $es - ($sm + $ss);
     return $Result;
 }
开发者ID:tautomers,项目名称:knoopvszombies,代码行数:29,代码来源:class.database.debug.php

示例8: fetchPageInfo

 public function fetchPageInfo($Url, $ThrowError = false)
 {
     $PageInfo = FetchPageInfo($Url, 3, $ThrowError);
     $Title = val('Title', $PageInfo, '');
     if ($Title == '') {
         if ($ThrowError) {
             throw new Gdn_UserException(t("The page didn't contain any information."));
         }
         $Title = formatString(t('Undefined discussion subject.'), array('Url' => $Url));
     } else {
         if ($Strip = c('Vanilla.Embed.StripPrefix')) {
             $Title = stringBeginsWith($Title, $Strip, true, true);
         }
         if ($Strip = c('Vanilla.Embed.StripSuffix')) {
             $Title = StringEndsWith($Title, $Strip, true, true);
         }
     }
     $Title = trim($Title);
     $Description = val('Description', $PageInfo, '');
     $Images = val('Images', $PageInfo, array());
     $Body = formatString(t('EmbeddedDiscussionFormat'), array('Title' => $Title, 'Excerpt' => $Description, 'Image' => count($Images) > 0 ? img(val(0, $Images), array('class' => 'LeftAlign')) : '', 'Url' => $Url));
     if ($Body == '') {
         $Body = $Url;
     }
     if ($Body == '') {
         $Body = formatString(t('EmbeddedNoBodyFormat.'), array('Url' => $Url));
     }
     $Result = array('Name' => $Title, 'Body' => $Body, 'Format' => 'Html');
     return $Result;
 }
开发者ID:RodSloan,项目名称:vanilla,代码行数:30,代码来源:class.discussionmodel.php

示例9: Join


//.........这里部分代码省略.........
                  break;
               case 'prefix':
                  $ColumnPrefix = $Name;
                  break;
               case 'table':
                  $Table = $Name;
                  break;
               case 'type':
                  // The type shouldn't be here, but handle it.
                  $Options['Type'] = $Name;
                  break;
               default:
                  throw new Exception("Gdn_DataSet::Join(): Unknown column option '$Index'.");
            }
         }
      }
      
      if (!isset($TableAlias)) {
         if (isset($Table))
            $TableAlias = 'c';
         else
            $TableAlias = 'c';
      }
      
      if (!isset($ParentColumn)) {
         if (isset($ChildColumn))
            $ParentColumn = $ChildColumn;
         elseif (isset($Table))
            $ChildColumn = $Table.'ID';
         else
            throw Exception("Gdn_DataSet::Join(): Missing 'parent' argument'.");
      }
      
      // Figure out some options if they weren't specified.
      if (!isset($ChildColumn)) {
         if (isset($ParentColumn))
            $ChildColumn = $ParentColumn;
         elseif (isset($Table))
            $ChildColumn = $Table.'ID';
         else
            throw Exception("Gdn_DataSet::Join(): Missing 'child' argument'.");
      }
      
      if (!isset($ColumnPrefix) && !isset($JoinColumn)) {
         $ColumnPrefix = StringEndsWith($ParentColumn, 'ID', TRUE, TRUE);
      }
      
      $JoinType = strtolower(GetValue('Type', $Options, JOIN_LEFT));
      
      // Start augmenting the sql for the join.
      if (isset($Table))
         $Sql->From("$Table $TableAlias");
      $Sql->Select("$TableAlias.$ChildColumn");
      
      // Get the IDs to generate an in clause with.
      $IDs = ConsolidateArrayValuesByKey($Data, $ParentColumn);
      $Sql->WhereIn($ChildColumn, $IDs);
      
      $ChildData = $Sql->Get()->ResultArray();
      $ChildData = self::Index($ChildData, $ChildColumn, array('unique' => isset($ColumnPrefix)));
      
      $NotFound = array();

      // Join the data in.
      foreach ($Data as $Index => &$Row) {
         $ParentID = GetValue($ParentColumn, $Row);
         if (isset($ChildData[$ParentID])) {
            $ChildRow = $ChildData[$ParentID];
            
            if (isset($ColumnPrefix)) {
               // Add the data to the columns.
               foreach ($ChildRow as $Name => $Value) {
                  SetValue($ColumnPrefix.$Name, $Row, $Value);
               }
            } else {
               // Add the result data.
               SetValue($JoinColumn, $Row, $ChildRow);
            }
         } else {
            if ($JoinType == JOIN_LEFT) {
               if (isset($ColumnPrefix)) {
                  foreach ($ResultColumns as $Name) {
                     SetValue($ColumnPrefix.$Name, $Row, NULL);
                  }
               } else {
                  SetValue($JoinColumn, $Row, array());
               }
            } else {
               $NotFound[] = $Index;
            }
         }
      }
      
      // Remove inner join rows.
      if ($JoinType == JOIN_INNER) {
         foreach ($NotFound as $Index) {
            unset($Data[$Index]);
         }
      }
   }
开发者ID:nerdgirl,项目名称:Forums-ILoveBadTV,代码行数:101,代码来源:class.dataset.php

示例10: UtilityController_SiteMap_Create

 public function UtilityController_SiteMap_Create($Sender, $Args = array())
 {
     Gdn::Session()->Start(0, FALSE, FALSE);
     $Sender->DeliveryMethod(DELIVERY_METHOD_XHTML);
     $Sender->DeliveryType(DELIVERY_TYPE_VIEW);
     $Sender->SetHeader('Content-Type', 'text/xml');
     $Arg = StringEndsWith(GetValue(0, $Args), '.xml', TRUE, TRUE);
     $Parts = explode('-', $Arg, 2);
     $Type = strtolower($Parts[0]);
     $Arg = GetValue(1, $Parts, '');
     $Urls = array();
     switch ($Type) {
         case 'category':
             // Build the category site map.
             $this->BuildCategorySiteMap($Arg, $Urls);
             break;
         default:
             // See if a plugin can build the sitemap.
             $this->EventArguments['Type'] = $Type;
             $this->EventArguments['Arg'] = $Arg;
             $this->EventArguments['Urls'] =& $Urls;
             $this->FireEvent('SiteMap' . ucfirst($Type));
             break;
     }
     $Sender->SetData('Urls', $Urls);
     $Sender->Render('SiteMap', '', 'plugins/Sitemaps');
 }
开发者ID:SatiricMan,项目名称:addons,代码行数:27,代码来源:class.sitemaps.plugin.php

示例11: ServeFile

 /**
  * Serves a file to the browser.
  *
  * @param string $File The full path to the file being served.
  * @param string $Name The name to give the file being served (don't include file extension, it will be added automatically). Will use file's name on disk if ignored.
  * @param string $MimeType The mime type of the file.
  */
 public static function ServeFile($File, $Name = '', $MimeType = '')
 {
     if (is_readable($File)) {
         // Get the db connection and make sure it is closed
         $Database = Gdn::Database();
         $Database->CloseConnection();
         $Size = filesize($File);
         $Extension = strtolower(pathinfo($File, PATHINFO_EXTENSION));
         if ($Name == '') {
             $Name = pathinfo($File, PATHINFO_FILENAME) . '.' . $Extension;
         } elseif (!StringEndsWith($Name, '.' . $Extension)) {
             $Name .= '.' . $Extension;
         }
         $Name = rawurldecode($Name);
         // Figure out the MIME type
         $MimeTypes = array("pdf" => "application/pdf", "txt" => "text/plain", "html" => "text/html", "htm" => "text/html", "exe" => "application/octet-stream", "zip" => "application/zip", "doc" => "application/msword", "xls" => "application/vnd.ms-excel", "ppt" => "application/vnd.ms-powerpoint", "gif" => "image/gif", "png" => "image/png", "jpeg" => "image/jpg", "jpg" => "image/jpg", "php" => "text/plain");
         if ($MimeType == '') {
             if (array_key_exists($Extension, $MimeTypes)) {
                 $MimeType = $MimeTypes[$Extension];
             } else {
                 $MimeType = 'application/force-download';
             }
         }
         @ob_end_clean();
         // required for IE, otherwise Content-Disposition may be ignored
         if (ini_get('zlib.output_compression')) {
             ini_set('zlib.output_compression', 'Off');
         }
         header('Content-Type: ' . $MimeType);
         header('Content-Disposition: attachment; filename="' . $Name . '"');
         header("Content-Transfer-Encoding: binary");
         header('Accept-Ranges: bytes');
         header("Cache-control: private");
         header('Pragma: private');
         header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
         readfile($File);
         exit;
     }
 }
开发者ID:kennyma,项目名称:Garden,代码行数:46,代码来源:class.filesystem.php

示例12: init

 /**
  *
  *
  * @param $Path
  * @param $Controller
  */
 public function init($Path, $Controller)
 {
     $Smarty = $this->smarty();
     // Get a friendly name for the controller.
     $ControllerName = get_class($Controller);
     if (StringEndsWith($ControllerName, 'Controller', true)) {
         $ControllerName = substr($ControllerName, 0, -10);
     }
     // Get an ID for the body.
     $BodyIdentifier = strtolower($Controller->ApplicationFolder . '_' . $ControllerName . '_' . Gdn_Format::alphaNumeric(strtolower($Controller->RequestMethod)));
     $Smarty->assign('BodyID', $BodyIdentifier);
     //$Smarty->assign('Config', Gdn::Config());
     // Assign some information about the user.
     $Session = Gdn::session();
     if ($Session->isValid()) {
         $User = array('Name' => $Session->User->Name, 'Photo' => '', 'CountNotifications' => (int) val('CountNotifications', $Session->User, 0), 'CountUnreadConversations' => (int) val('CountUnreadConversations', $Session->User, 0), 'SignedIn' => true);
         $Photo = $Session->User->Photo;
         if ($Photo) {
             if (!IsUrl($Photo)) {
                 $Photo = Gdn_Upload::Url(ChangeBasename($Photo, 'n%s'));
             }
         } else {
             if (function_exists('UserPhotoDefaultUrl')) {
                 $Photo = UserPhotoDefaultUrl($Session->User, 'ProfilePhoto');
             } elseif ($ConfigPhoto = C('Garden.DefaultAvatar')) {
                 $Photo = Gdn_Upload::url($ConfigPhoto);
             } else {
                 $Photo = Asset('/applications/dashboard/design/images/defaulticon.png', true);
             }
         }
         $User['Photo'] = $Photo;
     } else {
         $User = false;
         /*array(
           'Name' => '',
           'CountNotifications' => 0,
           'SignedIn' => FALSE);*/
     }
     $Smarty->assign('User', $User);
     // Make sure that any datasets use arrays instead of objects.
     foreach ($Controller->Data as $Key => $Value) {
         if ($Value instanceof Gdn_DataSet) {
             $Controller->Data[$Key] = $Value->resultArray();
         } elseif ($Value instanceof stdClass) {
             $Controller->Data[$Key] = (array) $Value;
         }
     }
     $BodyClass = val('CssClass', $Controller->Data, '', true);
     $Sections = Gdn_Theme::section(null, 'get');
     if (is_array($Sections)) {
         foreach ($Sections as $Section) {
             $BodyClass .= ' Section-' . $Section;
         }
     }
     $Controller->Data['BodyClass'] = $BodyClass;
     // Set the current locale for themes to take advantage of.
     $Locale = Gdn::locale()->Locale;
     $CurrentLocale = array('Key' => $Locale, 'Lang' => str_replace('_', '-', $Locale));
     if (class_exists('Locale')) {
         $CurrentLocale['Language'] = Locale::getPrimaryLanguage($Locale);
         $CurrentLocale['Region'] = Locale::getRegion($Locale);
         $CurrentLocale['DisplayName'] = Locale::getDisplayName($Locale, $Locale);
         $CurrentLocale['DisplayLanguage'] = Locale::getDisplayLanguage($Locale, $Locale);
         $CurrentLocale['DisplayRegion'] = Locale::getDisplayRegion($Locale, $Locale);
     }
     $Smarty->assign('CurrentLocale', $CurrentLocale);
     $Smarty->assign('Assets', (array) $Controller->Assets);
     $Smarty->assign('Path', Gdn::request()->path());
     // Assign the controller data last so the controllers override any default data.
     $Smarty->assign($Controller->Data);
     $Smarty->Controller = $Controller;
     // for smarty plugins
     $Smarty->security = true;
     $Smarty->security_settings['IF_FUNCS'] = array_merge($Smarty->security_settings['IF_FUNCS'], array('Category', 'CheckPermission', 'InSection', 'InCategory', 'MultiCheckPermission', 'GetValue', 'SetValue', 'Url'));
     $Smarty->security_settings['MODIFIER_FUNCS'] = array_merge($Smarty->security_settings['MODIFIER_FUNCS'], array('sprintf'));
     $Smarty->secure_dir = array($Path);
 }
开发者ID:karanjitsingh,项目名称:iecse-forum,代码行数:83,代码来源:class.smarty.php

示例13: InsertPermissionTable

 public function InsertPermissionTable()
 {
     if ($this->ImportExists('Permission', 'JunctionTable')) {
         $this->_InsertTable('Permission');
         return TRUE;
     }
     // Clear the permission table in case the step was only half done before.
     $this->SQL->Delete('Permission', array('RoleID <>' => 0));
     // Grab all of the permission columns.
     $PM = new PermissionModel();
     $GlobalColumns = array_filter($PM->PermissionColumns());
     unset($GlobalColumns['PermissionID']);
     $JunctionColumns = array_filter($PM->PermissionColumns('Category', 'PermissionCategoryID'));
     unset($JunctionColumns['PermissionID']);
     $JunctionColumns = array_merge(array('JunctionTable' => 'Category', 'JunctionColumn' => 'PermissionCategoryID', 'JunctionID' => -1), $JunctionColumns);
     $ColumnSets = array($GlobalColumns, $JunctionColumns);
     $Data = $this->SQL->Get('zPermission')->ResultArray();
     foreach ($Data as $Row) {
         $Preset = strtolower(GetValue('_Permissions', $Row));
         foreach ($ColumnSets as $ColumnSet) {
             $Set = array();
             $Set['RoleID'] = $Row['RoleID'];
             foreach ($ColumnSet as $ColumnName => $Default) {
                 if (isset($Row[$ColumnName])) {
                     $Value = $Row[$ColumnName];
                 } elseif (strpos($ColumnName, '.') === FALSE) {
                     $Value = $Default;
                 } elseif ($Preset == 'all') {
                     $Value = 1;
                 } elseif ($Preset == 'view') {
                     $Value = StringEndsWith($ColumnName, 'View', TRUE);
                 } else {
                     $Value = $Default & 1;
                 }
                 $Set["`{$ColumnName}`"] = $Value;
             }
             $this->SQL->Insert('Permission', $Set);
             unset($Set);
         }
     }
     return TRUE;
 }
开发者ID:seedbank,项目名称:old-repo,代码行数:42,代码来源:class.importmodel.php

示例14: InsertPermissionTable

 public function InsertPermissionTable()
 {
     //      $this->LoadState();
     // Clear the permission table in case the step was only half done before.
     $this->SQL->Delete('Permission', array('RoleID <>' => 0));
     // Grab all of the permission columns.
     $PM = new PermissionModel();
     $GlobalColumns = array_filter($PM->PermissionColumns());
     unset($GlobalColumns['PermissionID']);
     $JunctionColumns = array_filter($PM->PermissionColumns('Category', 'PermissionCategoryID'));
     unset($JunctionColumns['PermissionID']);
     $JunctionColumns = array_merge(array('JunctionTable' => 'Category', 'JunctionColumn' => 'PermissionCategoryID', 'JunctionID' => -1), $JunctionColumns);
     if ($this->ImportExists('Permission', 'JunctionTable')) {
         $ColumnSets = array(array_merge($GlobalColumns, $JunctionColumns));
         $ColumnSets[0]['JunctionTable'] = NULL;
         $ColumnSets[0]['JunctionColumn'] = NULL;
         $ColumnSets[0]['JunctionID'] = NULL;
     } else {
         $ColumnSets = array($GlobalColumns, $JunctionColumns);
     }
     $Data = $this->SQL->Get('zPermission')->ResultArray();
     foreach ($Data as $Row) {
         $Presets = array_map('trim', explode(',', GetValue('_Permissions', $Row)));
         foreach ($ColumnSets as $ColumnSet) {
             $Set = array();
             $Set['RoleID'] = $Row['RoleID'];
             foreach ($Presets as $Preset) {
                 if (strpos($Preset, '.') !== FALSE) {
                     // This preset is a specific permission.
                     if (array_key_exists($Preset, $ColumnSet)) {
                         $Set["`{$Preset}`"] = 1;
                     }
                     continue;
                 }
                 $Preset = strtolower($Preset);
                 foreach ($ColumnSet as $ColumnName => $Default) {
                     if (isset($Row[$ColumnName])) {
                         $Value = $Row[$ColumnName];
                     } elseif (strpos($ColumnName, '.') === FALSE) {
                         $Value = $Default;
                     } elseif ($Preset == 'all') {
                         $Value = 1;
                     } elseif ($Preset == 'view') {
                         $Value = StringEndsWith($ColumnName, 'View', TRUE) && !in_array($ColumnName, array('Garden.Settings.View'));
                     } elseif ($Preset == $ColumnName) {
                         $Value = 1;
                     } else {
                         $Value = $Default & 1;
                     }
                     $Set["`{$ColumnName}`"] = $Value;
                 }
             }
             $this->SQL->Insert('Permission', $Set);
             unset($Set);
         }
     }
     return TRUE;
 }
开发者ID:elpum,项目名称:TgaForumBundle,代码行数:58,代码来源:class.importmodel.php

示例15: parseInfoArray

 /**
  * Offers a quick and dirty way of parsing an addon's info array without using eval().
  *
  * @param string $Path The path to the info array.
  * @param string $Variable The name of variable containing the information.
  * @return array|false The info array or false if the file could not be parsed.
  */
 public static function parseInfoArray($Path, $Variable = false)
 {
     $fp = fopen($Path, 'rb');
     $Lines = array();
     $InArray = false;
     // Get all of the lines in the info array.
     while (($Line = fgets($fp)) !== false) {
         // Remove comments from the line.
         $Line = preg_replace('`\\s//.*$`', '', $Line);
         if (!$Line) {
             continue;
         }
         if (!$InArray && preg_match('`\\$([A-Za-z]+Info)\\s*\\[`', trim($Line), $Matches)) {
             $Variable = $Matches[1];
             if (preg_match('`\\[\\s*[\'"](.+?)[\'"]\\s*\\]`', $Line, $Matches)) {
                 $GlobalKey = $Matches[1];
                 $InArray = true;
             }
         } elseif ($InArray && StringEndsWith(trim($Line), ';')) {
             break;
         } elseif ($InArray) {
             $Lines[] = trim($Line);
         }
     }
     fclose($fp);
     if (count($Lines) == 0) {
         return false;
     }
     // Parse the name/value information in the arrays.
     $Result = array();
     foreach ($Lines as $Line) {
         // Get the name from the line.
         if (!preg_match('`[\'"](.+?)[\'"]\\s*=>`', $Line, $Matches) || !substr($Line, -1) == ',') {
             continue;
         }
         $Key = $Matches[1];
         // Strip the key from the line.
         $Line = trim(trim(substr(strstr($Line, '=>'), 2)), ',');
         if (strlen($Line) == 0) {
             continue;
         }
         $Value = null;
         if (is_numeric($Line)) {
             $Value = $Line;
         } elseif (strcasecmp($Line, 'TRUE') == 0 || strcasecmp($Line, 'FALSE') == 0) {
             $Value = $Line;
         } elseif (in_array($Line[0], array('"', "'")) && substr($Line, -1) == $Line[0]) {
             $Quote = $Line[0];
             $Value = trim($Line, $Quote);
             $Value = str_replace('\\' . $Quote, $Quote, $Value);
         } elseif (stringBeginsWith($Line, 'array(') && substr($Line, -1) == ')') {
             // Parse the line's array.
             $Line = substr($Line, 6, strlen($Line) - 7);
             $Items = explode(',', $Line);
             $Array = array();
             foreach ($Items as $Item) {
                 $SubItems = explode('=>', $Item);
                 if (count($SubItems) == 1) {
                     $Array[] = trim(trim($SubItems[0]), '"\'');
                 } elseif (count($SubItems) == 2) {
                     $SubKey = trim(trim($SubItems[0]), '"\'');
                     $SubValue = trim(trim($SubItems[1]), '"\'');
                     $Array[$SubKey] = $SubValue;
                 }
             }
             $Value = $Array;
         }
         if ($Value != null) {
             $Result[$Key] = $Value;
         }
     }
     $Result = array($GlobalKey => $Result, 'Variable' => $Variable);
     return $Result;
 }
开发者ID:caidongyun,项目名称:vanilla,代码行数:81,代码来源:class.updatemodel.php


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