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


PHP Plugins::get方法代码示例

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


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

示例1: get

 /**
  * @return array|false Returns an array of albums or false on failure.
  */
 public function get($public = true)
 {
     // Call plugins
     Plugins::get()->activate(__METHOD__, 0, func_get_args());
     // Initialize return var
     $return = array('smartalbums' => null, 'albums' => null, 'num' => 0);
     // Get SmartAlbums
     if ($public === false) {
         $return['smartalbums'] = $this->getSmartAlbums();
     }
     // Albums query
     if ($public === false) {
         $query = Database::prepare(Database::get(), 'SELECT id, title, public, sysstamp, password FROM ? ' . Settings::get()['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
     } else {
         $query = Database::prepare(Database::get(), 'SELECT id, title, public, sysstamp, password FROM ? WHERE public = 1 AND visible <> 0 ' . Settings::get()['sortingAlbums'], array(LYCHEE_TABLE_ALBUMS));
     }
     // Execute query
     $albums = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
     if ($albums === false) {
         return false;
     }
     // For each album
     while ($album = $albums->fetch_assoc()) {
         // Turn data from the database into a front-end friendly format
         $album = Album::prepareData($album);
         // Thumbs
         if ($public === true && $album['password'] === '0' || $public === false) {
             // Execute query
             $query = Database::prepare(Database::get(), "SELECT thumbUrl FROM ? WHERE album = '?' ORDER BY star DESC, " . substr(Settings::get()['sortingPhotos'], 9) . " LIMIT 3", array(LYCHEE_TABLE_PHOTOS, $album['id']));
             $thumbs = Database::execute(Database::get(), $query, __METHOD__, __LINE__);
             if ($thumbs === false) {
                 return false;
             }
             // For each thumb
             $k = 0;
             while ($thumb = $thumbs->fetch_object()) {
                 $album['thumbs'][$k] = LYCHEE_URL_UPLOADS_THUMB . $thumb->thumbUrl;
                 $k++;
             }
         }
         // Add to return
         $return['albums'][] = $album;
     }
     // Num of albums
     $return['num'] = $albums->num_rows;
     // Call plugins
     Plugins::get()->activate(__METHOD__, 1, func_get_args());
     return $return;
 }
开发者ID:windhamdavid,项目名称:Lychee,代码行数:52,代码来源:Albums.php

示例2: logout

 /**
  * Unsets the session values.
  * @return boolean Returns true when logout was successful.
  */
 public function logout()
 {
     // Call plugins
     Plugins::get()->activate(__METHOD__, 0, func_get_args());
     session_unset();
     session_destroy();
     // Call plugins
     Plugins::get()->activate(__METHOD__, 1, func_get_args());
     return true;
 }
开发者ID:windhamdavid,项目名称:Lychee,代码行数:14,代码来源:Session.php

示例3: server

 /**
  * @return boolean|string Returns true when successful.
  *                        Warning: Folder empty or no readable files to process!
  *                        Notice: Import only contained albums!
  */
 public function server($path, $albumID = 0)
 {
     // Parse path
     if (!isset($path)) {
         $path = LYCHEE_UPLOADS_IMPORT;
     }
     if (substr($path, -1) === '/') {
         $path = substr($path, 0, -1);
     }
     if (is_dir($path) === false) {
         Log::error(Database::get(), __METHOD__, __LINE__, 'Given path is not a directory (' . $path . ')');
         return false;
     }
     // Skip folders of Lychee
     if ($path === LYCHEE_UPLOADS_BIG || $path . '/' === LYCHEE_UPLOADS_BIG || $path === LYCHEE_UPLOADS_MEDIUM || $path . '/' === LYCHEE_UPLOADS_MEDIUM || $path === LYCHEE_UPLOADS_THUMB || $path . '/' === LYCHEE_UPLOADS_THUMB) {
         Log::error(Database::get(), __METHOD__, __LINE__, 'The given path is a reserved path of Lychee (' . $path . ')');
         return false;
     }
     $error = false;
     $contains['photos'] = false;
     $contains['albums'] = false;
     // Call plugins
     // Note that updated albumId and path explicitly passed, rather
     // than using func_get_args() which will only return original ones
     Plugins::get()->activate(__METHOD__, 0, array($albumID, $path));
     // Get all files
     $files = glob($path . '/*');
     foreach ($files as $file) {
         // It is possible to move a file because of directory permissions but
         // the file may still be unreadable by the user
         if (!is_readable($file)) {
             $error = true;
             Log::error(Database::get(), __METHOD__, __LINE__, 'Could not read file or directory (' . $file . ')');
             continue;
         }
         if (@exif_imagetype($file) !== false) {
             // Photo
             $contains['photos'] = true;
             if ($this->photo($file, $albumID) === false) {
                 $error = true;
                 Log::error(Database::get(), __METHOD__, __LINE__, 'Could not import file (' . $file . ')');
                 continue;
             }
         } else {
             if (is_dir($file)) {
                 // Folder
                 $album = new Album(null);
                 $newAlbumID = $album->add('[Import] ' . basename($file));
                 $contains['albums'] = true;
                 if ($newAlbumID === false) {
                     $error = true;
                     Log::error(Database::get(), __METHOD__, __LINE__, 'Could not create album in Lychee (' . $newAlbumID . ')');
                     continue;
                 }
                 $import = $this->server($file . '/', $newAlbumID);
                 if ($import !== true && $import !== 'Notice: Import only contains albums!') {
                     $error = true;
                     Log::error(Database::get(), __METHOD__, __LINE__, 'Could not import folder. Function returned warning.');
                     continue;
                 }
             }
         }
     }
     // Call plugins
     // Note that updated albumId and path explicitly passed, rather
     // than using func_get_args() which will only return original ones
     Plugins::get()->activate(__METHOD__, 1, array($albumID, $path));
     // The following returns will be caught in the front-end
     if ($contains['photos'] === false && $contains['albums'] === false) {
         return 'Warning: Folder empty or no readable files to process!';
     }
     if ($contains['photos'] === false && $contains['albums'] === true) {
         return 'Notice: Import only contained albums!';
     }
     if ($error === true) {
         return false;
     }
     return true;
 }
开发者ID:windhamdavid,项目名称:Lychee,代码行数:84,代码来源:Import.php


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