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


PHP File::staticGet方法代码示例

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


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

示例1: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $args misc. arguments
  *
  * @return boolean true
  */
 function prepare($args)
 {
     parent::prepare($args);
     if (!$this->isPost()) {
         throw new ClientException(_('POST only'), 405);
     }
     $this->checkSessionToken();
     $this->url = $this->trimmed('url');
     if (empty($this->url)) {
         throw new ClientException(_('URL is required.'), 400);
     }
     if (!Validate::uri($this->url, array('allowed_schemes' => array('http', 'https')))) {
         throw new ClientException(_('Invalid URL.'), 400);
     }
     $f = File::staticGet('url', $this->url);
     if (empty($url)) {
         $f = File::processNew($this->url);
     }
     // How about now?
     if (!empty($f)) {
         $this->oembed = File_oembed::staticGet('file_id', $f->id);
         if (!empty($this->oembed)) {
             $this->title = $this->oembed->title;
         }
         $this->thumbnail = File_thumbnail::staticGet('file_id', $f->id);
     }
     return true;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:35,代码来源:bookmarkforurl.php

示例2: delete

 function delete()
 {
     $f = File::staticGet('id', $this->file_id);
     if (!empty($f)) {
         $f->blowCache();
     }
     return parent::delete();
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:8,代码来源:File_to_post.php

示例3: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->file = File::staticGet('id', $this->trimmed('id'));
     if (empty($this->file)) {
         throw new ClientException(_('Unknown URL'));
     }
     $pageArg = $this->trimmed('page');
     $this->page = empty($pageArg) ? 1 : intval($pageArg);
     $this->notices = $this->file->stream(($this->page - 1) * NOTICES_PER_PAGE, NOTICES_PER_PAGE + 1);
     return true;
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:19,代码来源:noticebyurl.php

示例4: prepare

 /**
  * Load attributes based on database arguments
  *
  * Loads all the DB stuff
  *
  * @param array $args $_REQUEST array
  *
  * @return success flag
  */
 function prepare($args)
 {
     parent::prepare($args);
     if ($id = $this->trimmed('attachment')) {
         $this->attachment = File::staticGet($id);
     }
     if (empty($this->attachment)) {
         $this->clientError(_('No such attachment.'), 404);
         return false;
     }
     return true;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:21,代码来源:attachment.php

示例5: prepare

 /**
  * For initializing members of the class.
  *
  * @param array $argarray misc. arguments
  *
  * @return boolean true
  */
 function prepare($argarray)
 {
     parent::prepare($argarray);
     $this->id = $this->trimmed('id');
     if (empty($this->id)) {
         // TRANS: Client exception thrown when no ID parameter was provided.
         throw new ClientException(_('No id parameter.'));
     }
     $this->file = File::staticGet('id', $this->id);
     if (empty($this->file)) {
         // TRANS: Client exception thrown when an invalid ID parameter was provided for a file.
         // TRANS: %d is the provided ID for which the file is not present (number).
         throw new ClientException(sprintf(_('No such file "%d".'), $this->id), 404);
     }
     return true;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:23,代码来源:redirecturl.php

示例6: handle

 function handle($args)
 {
     common_debug("in oembed api action");
     $url = $args['url'];
     if (substr(strtolower($url), 0, strlen(common_root_url())) == strtolower(common_root_url())) {
         $path = substr($url, strlen(common_root_url()));
         $r = Router::get();
         $proxy_args = $r->map($path);
         if (!$proxy_args) {
             // TRANS: Server error displayed in oEmbed action when path not found.
             // TRANS: %s is a path.
             $this->serverError(sprintf(_('"%s" not found.'), $path), 404);
         }
         $oembed = array();
         $oembed['version'] = '1.0';
         $oembed['provider_name'] = common_config('site', 'name');
         $oembed['provider_url'] = common_root_url();
         switch ($proxy_args['action']) {
             case 'shownotice':
                 $oembed['type'] = 'link';
                 $id = $proxy_args['notice'];
                 $notice = Notice::staticGet($id);
                 if (empty($notice)) {
                     // TRANS: Server error displayed in oEmbed action when notice not found.
                     // TRANS: %s is a notice.
                     $this->serverError(sprintf(_("Notice %s not found."), $id), 404);
                 }
                 $profile = $notice->getProfile();
                 if (empty($profile)) {
                     // TRANS: Server error displayed in oEmbed action when notice has not profile.
                     $this->serverError(_('Notice has no profile.'), 500);
                 }
                 $authorname = $profile->getFancyName();
                 // TRANS: oEmbed title. %1$s is the author name, %2$s is the creation date.
                 $oembed['title'] = sprintf(_('%1$s\'s status on %2$s'), $authorname, common_exact_date($notice->created));
                 $oembed['author_name'] = $authorname;
                 $oembed['author_url'] = $profile->profileurl;
                 $oembed['url'] = $notice->url ? $notice->url : $notice->uri;
                 $oembed['html'] = $notice->rendered;
                 break;
             case 'attachment':
                 $id = $proxy_args['attachment'];
                 $attachment = File::staticGet($id);
                 if (empty($attachment)) {
                     // TRANS: Server error displayed in oEmbed action when attachment not found.
                     // TRANS: %d is an attachment ID.
                     $this->serverError(sprintf(_('Attachment %s not found.'), $id), 404);
                 }
                 if (empty($attachment->filename) && ($file_oembed = File_oembed::staticGet('file_id', $attachment->id))) {
                     // Proxy the existing oembed information
                     $oembed['type'] = $file_oembed->type;
                     $oembed['provider'] = $file_oembed->provider;
                     $oembed['provider_url'] = $file_oembed->provider_url;
                     $oembed['width'] = $file_oembed->width;
                     $oembed['height'] = $file_oembed->height;
                     $oembed['html'] = $file_oembed->html;
                     $oembed['title'] = $file_oembed->title;
                     $oembed['author_name'] = $file_oembed->author_name;
                     $oembed['author_url'] = $file_oembed->author_url;
                     $oembed['url'] = $file_oembed->url;
                 } else {
                     if (substr($attachment->mimetype, 0, strlen('image/')) == 'image/') {
                         $oembed['type'] = 'photo';
                         if ($attachment->filename) {
                             $filepath = File::path($attachment->filename);
                             $gis = @getimagesize($filepath);
                             if ($gis) {
                                 $oembed['width'] = $gis[0];
                                 $oembed['height'] = $gis[1];
                             } else {
                                 // TODO Either throw an error or find a fallback?
                             }
                         }
                         $oembed['url'] = $attachment->url;
                         $thumb = $attachment->getThumbnail();
                         if ($thumb) {
                             $oembed['thumbnail_url'] = $thumb->url;
                             $oembed['thumbnail_width'] = $thumb->width;
                             $oembed['thumbnail_height'] = $thumb->height;
                         }
                     } else {
                         $oembed['type'] = 'link';
                         $oembed['url'] = common_local_url('attachment', array('attachment' => $attachment->id));
                     }
                 }
                 if ($attachment->title) {
                     $oembed['title'] = $attachment->title;
                 }
                 break;
             default:
                 // TRANS: Server error displayed in oEmbed request when a path is not supported.
                 // TRANS: %s is a path.
                 $this->serverError(sprintf(_('"%s" not supported for oembed requests.'), $path), 501);
         }
         switch ($args['format']) {
             case 'xml':
                 $this->init_document('xml');
                 $this->elementStart('oembed');
                 $this->element('version', null, $oembed['version']);
                 $this->element('type', null, $oembed['type']);
//.........这里部分代码省略.........
开发者ID:Grasia,项目名称:bolotweet,代码行数:101,代码来源:oembed.php

示例7: showLogo

 /**
  * Show configured logo.
  *
  * @return nothing
  */
 function showLogo()
 {
     $this->elementStart('address', array('id' => 'site_contact', 'class' => 'vcard'));
     if (Event::handle('StartAddressData', array($this))) {
         if (common_config('singleuser', 'enabled')) {
             $user = User::singleUser();
             $url = common_local_url('showstream', array('nickname' => $user->nickname));
         } else {
             $url = common_local_url('public');
         }
         $this->elementStart('a', array('class' => 'url home bookmark', 'href' => $url));
         if (StatusNet::isHTTPS()) {
             $logoUrl = common_config('site', 'ssllogo');
             if (empty($logoUrl)) {
                 // if logo is an uploaded file, try to fall back to HTTPS file URL
                 $httpUrl = common_config('site', 'logo');
                 if (!empty($httpUrl)) {
                     $f = File::staticGet('url', $httpUrl);
                     if (!empty($f) && !empty($f->filename)) {
                         // this will handle the HTTPS case
                         $logoUrl = File::url($f->filename);
                     }
                 }
             }
         } else {
             $logoUrl = common_config('site', 'logo');
         }
         if (empty($logoUrl) && file_exists(Theme::file('logo.png'))) {
             // This should handle the HTTPS case internally
             $logoUrl = Theme::path('logo.png');
         }
         if (!empty($logoUrl)) {
             $this->element('img', array('class' => 'logo photo', 'src' => $logoUrl, 'alt' => common_config('site', 'name')));
         }
         $this->text(' ');
         $this->element('span', array('class' => 'fn org'), common_config('site', 'name'));
         $this->elementEnd('a');
         Event::handle('EndAddressData', array($this));
     }
     $this->elementEnd('address');
 }
开发者ID:microcosmx,项目名称:experiments,代码行数:46,代码来源:action.php

示例8: _userMakeShort

 function _userMakeShort($long_url, User $user = null, $force = false)
 {
     $short_url = common_shorten_url($long_url, $user, $force);
     if (!empty($short_url) && $short_url != $long_url) {
         $short_url = (string) $short_url;
         // store it
         $file = File::staticGet('url', $long_url);
         if (empty($file)) {
             // Check if the target URL is itself a redirect...
             $redir_data = File_redirection::where($long_url);
             if (is_array($redir_data)) {
                 // We haven't seen the target URL before.
                 // Save file and embedding data about it!
                 $file = File::saveNew($redir_data, $long_url);
                 $file_id = $file->id;
                 if (!empty($redir_data['oembed']['json'])) {
                     File_oembed::saveNew($redir_data['oembed']['json'], $file_id);
                 }
             } else {
                 if (is_string($redir_data)) {
                     // The file is a known redirect target.
                     $file = File::staticGet('url', $redir_data);
                     if (empty($file)) {
                         // @fixme should we save a new one?
                         // this case was triggering sometimes for redirects
                         // with unresolvable targets; found while fixing
                         // "can't linkify" bugs with shortened links to
                         // SSL sites with cert issues.
                         return null;
                     }
                     $file_id = $file->id;
                 }
             }
         } else {
             $file_id = $file->id;
         }
         $file_redir = File_redirection::staticGet('url', $short_url);
         if (empty($file_redir)) {
             $file_redir = new File_redirection();
             $file_redir->url = $short_url;
             $file_redir->file_id = $file_id;
             $file_redir->insert();
         }
         return $short_url;
     }
     return null;
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:47,代码来源:File_redirection.php

示例9: _userMakeShort

 function _userMakeShort($long_url)
 {
     $short_url = common_shorten_url($long_url);
     if (!empty($short_url) && $short_url != $long_url) {
         $short_url = (string) $short_url;
         // store it
         $file = File::staticGet('url', $long_url);
         if (empty($file)) {
             $redir_data = File_redirection::where($long_url);
             $file = File::saveNew($redir_data, $long_url);
             $file_id = $file->id;
             if (!empty($redir_data['oembed']['json'])) {
                 File_oembed::saveNew($redir_data['oembed']['json'], $file_id);
             }
         } else {
             $file_id = $file->id;
         }
         $file_redir = File_redirection::staticGet('url', $short_url);
         if (empty($file_redir)) {
             $file_redir = new File_redirection();
             $file_redir->url = $short_url;
             $file_redir->file_id = $file_id;
             $file_redir->insert();
         }
         return $short_url;
     }
     return null;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:28,代码来源:File_redirection.php

示例10: attachments

 function attachments()
 {
     // XXX: cache this
     $att = array();
     $f2p = new File_to_post();
     $f2p->post_id = $this->id;
     if ($f2p->find()) {
         while ($f2p->fetch()) {
             $f = File::staticGet($f2p->file_id);
             if ($f) {
                 $att[] = clone $f;
             }
         }
     }
     return $att;
 }
开发者ID:Br3nda,项目名称:statusnet-debian,代码行数:16,代码来源:Notice.php

示例11: processNew

 function processNew($given_url, $notice_id)
 {
     if (empty($given_url)) {
         return -1;
     }
     // error, no url to process
     $given_url = File_redirection::_canonUrl($given_url);
     if (empty($given_url)) {
         return -1;
     }
     // error, no url to process
     $file = File::staticGet('url', $given_url);
     if (empty($file)) {
         $file_redir = File_redirection::staticGet('url', $given_url);
         if (empty($file_redir)) {
             common_debug("processNew() '{$given_url}' not a known redirect.\n");
             $redir_data = File_redirection::where($given_url);
             $redir_url = $redir_data['url'];
             if ($redir_url === $given_url) {
                 $x = File::saveNew($redir_data, $given_url);
                 $file_id = $x->id;
             } else {
                 $x = File::processNew($redir_url, $notice_id);
                 $file_id = $x->id;
                 File_redirection::saveNew($redir_data, $file_id, $given_url);
             }
         } else {
             $file_id = $file_redir->file_id;
         }
     } else {
         $file_id = $file->id;
         $x = $file;
     }
     if (empty($x)) {
         $x = File::staticGet($file_id);
         if (empty($x)) {
             die('Impossible!');
         }
     }
     File_to_post::processNew($file_id, $notice_id);
     return $x;
 }
开发者ID:Br3nda,项目名称:laconica,代码行数:42,代码来源:File.php

示例12: saveNew

 /**
  * Save embedding info for a new file.
  *
  * @param object $data Services_oEmbed_Object_*
  * @param int $file_id
  */
 function saveNew($data, $file_id)
 {
     $file_oembed = new File_oembed();
     $file_oembed->file_id = $file_id;
     $file_oembed->version = $data->version;
     $file_oembed->type = $data->type;
     if (!empty($data->provider_name)) {
         $file_oembed->provider = $data->provider_name;
     }
     if (!empty($data->provider)) {
         $file_oembed->provider = $data->provider;
     }
     if (!empty($data->provide_url)) {
         $file_oembed->provider_url = $data->provider_url;
     }
     if (!empty($data->width)) {
         $file_oembed->width = intval($data->width);
     }
     if (!empty($data->height)) {
         $file_oembed->height = intval($data->height);
     }
     if (!empty($data->html)) {
         $file_oembed->html = $data->html;
     }
     if (!empty($data->title)) {
         $file_oembed->title = $data->title;
     }
     if (!empty($data->author_name)) {
         $file_oembed->author_name = $data->author_name;
     }
     if (!empty($data->author_url)) {
         $file_oembed->author_url = $data->author_url;
     }
     if (!empty($data->url)) {
         $file_oembed->url = $data->url;
         $given_url = File_redirection::_canonUrl($file_oembed->url);
         if (!empty($given_url)) {
             $file = File::staticGet('url', $given_url);
             if (empty($file)) {
                 $file_redir = File_redirection::staticGet('url', $given_url);
                 if (empty($file_redir)) {
                     $redir_data = File_redirection::where($given_url);
                     $file_oembed->mimetype = $redir_data['type'];
                 } else {
                     $file_id = $file_redir->file_id;
                 }
             } else {
                 $file_oembed->mimetype = $file->mimetype;
             }
         }
     }
     $file_oembed->insert();
     if (!empty($data->thumbnail_url) || $data->type == 'photo') {
         $ft = File_thumbnail::staticGet('file_id', $file_id);
         if (!empty($ft)) {
             common_log(LOG_WARNING, "Strangely, a File_thumbnail object exists for new file {$file_id}", __FILE__);
         } else {
             File_thumbnail::saveNew($data, $file_id);
         }
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:67,代码来源:File_oembed.php

示例13: common_linkify

function common_linkify($url)
{
    // It comes in special'd, so we unspecial it before passing to the stringifying
    // functions
    $url = htmlspecialchars_decode($url);
    if (strpos($url, '@') !== false && strpos($url, ':') === false && Validate::email($url)) {
        //url is an email address without the mailto: protocol
        $canon = "mailto:{$url}";
        $longurl = "mailto:{$url}";
    } else {
        $canon = File_redirection::_canonUrl($url);
        $longurl_data = File_redirection::where($canon, common_config('attachments', 'process_links'));
        if (is_array($longurl_data)) {
            $longurl = $longurl_data['url'];
        } elseif (is_string($longurl_data)) {
            $longurl = $longurl_data;
        } else {
            // Unable to reach the server to verify contents, etc
            // Just pass the link on through for now.
            common_log(LOG_ERR, "Can't linkify url '{$url}'");
            $longurl = $url;
        }
    }
    $attrs = array('href' => $canon, 'title' => $longurl);
    $is_attachment = false;
    $attachment_id = null;
    $has_thumb = false;
    // Check to see whether this is a known "attachment" URL.
    $f = File::staticGet('url', $longurl);
    if (empty($f)) {
        if (common_config('attachments', 'process_links')) {
            // XXX: this writes to the database. :<
            $f = File::processNew($longurl);
        }
    }
    if (!empty($f)) {
        if ($f->getEnclosure()) {
            $is_attachment = true;
            $attachment_id = $f->id;
            $thumb = File_thumbnail::staticGet('file_id', $f->id);
            if (!empty($thumb)) {
                $has_thumb = true;
            }
        }
    }
    // Add clippy
    if ($is_attachment) {
        $attrs['class'] = 'attachment';
        if ($has_thumb) {
            $attrs['class'] = 'attachment thumbnail';
        }
        $attrs['id'] = "attachment-{$attachment_id}";
    }
    // Whether to nofollow
    $nf = common_config('nofollow', 'external');
    if ($nf == 'never') {
        $attrs['rel'] = 'external';
    } else {
        $attrs['rel'] = 'nofollow external';
    }
    return XMLStringer::estring('a', $attrs, $url);
}
开发者ID:harriewang,项目名称:InnertieWebsite,代码行数:62,代码来源:util.php

示例14: processNew

 function processNew($given_url, $notice_id = null)
 {
     if (empty($given_url)) {
         return -1;
     }
     // error, no url to process
     $given_url = File_redirection::_canonUrl($given_url);
     if (empty($given_url)) {
         return -1;
     }
     // error, no url to process
     $file = File::staticGet('url', $given_url);
     if (empty($file)) {
         $file_redir = File_redirection::staticGet('url', $given_url);
         if (empty($file_redir)) {
             $redir_data = File_redirection::where($given_url);
             if (is_array($redir_data)) {
                 $redir_url = $redir_data['url'];
             } elseif (is_string($redir_data)) {
                 $redir_url = $redir_data;
                 $redir_data = array();
             } else {
                 throw new ServerException("Can't process url '{$given_url}'");
             }
             // TODO: max field length
             if ($redir_url === $given_url || strlen($redir_url) > 255) {
                 $x = File::saveNew($redir_data, $given_url);
                 $file_id = $x->id;
             } else {
                 $x = File::processNew($redir_url, $notice_id);
                 $file_id = $x->id;
                 File_redirection::saveNew($redir_data, $file_id, $given_url);
             }
         } else {
             $file_id = $file_redir->file_id;
         }
     } else {
         $file_id = $file->id;
         $x = $file;
     }
     if (empty($x)) {
         $x = File::staticGet($file_id);
         if (empty($x)) {
             throw new ServerException("Robin thinks something is impossible.");
         }
     }
     if (!empty($notice_id)) {
         File_to_post::processNew($file_id, $notice_id);
     }
     return $x;
 }
开发者ID:himmelex,项目名称:NTW,代码行数:51,代码来源:File.php

示例15: common_linkify

function common_linkify($url)
{
    // It comes in special'd, so we unspecial it before passing to the stringifying
    // functions
    $url = htmlspecialchars_decode($url);
    if (strpos($url, '@') !== false && strpos($url, ':') === false) {
        //url is an email address without the mailto: protocol
        $canon = "mailto:{$url}";
        $longurl = "mailto:{$url}";
    } else {
        $canon = File_redirection::_canonUrl($url);
        $longurl_data = File_redirection::where($canon);
        if (is_array($longurl_data)) {
            $longurl = $longurl_data['url'];
        } elseif (is_string($longurl_data)) {
            $longurl = $longurl_data;
        } else {
            throw new ServerException("Can't linkify url '{$url}'");
        }
    }
    $attrs = array('href' => $canon, 'title' => $longurl, 'rel' => 'external');
    $is_attachment = false;
    $attachment_id = null;
    $has_thumb = false;
    // Check to see whether this is a known "attachment" URL.
    $f = File::staticGet('url', $longurl);
    if (empty($f)) {
        // XXX: this writes to the database. :<
        $f = File::processNew($longurl);
    }
    if (!empty($f)) {
        if ($f->getEnclosure()) {
            $is_attachment = true;
            $attachment_id = $f->id;
            $thumb = File_thumbnail::staticGet('file_id', $f->id);
            if (!empty($thumb)) {
                $has_thumb = true;
            }
        }
    }
    // Add clippy
    if ($is_attachment) {
        $attrs['class'] = 'attachment';
        if ($has_thumb) {
            $attrs['class'] = 'attachment thumbnail';
        }
        $attrs['id'] = "attachment-{$attachment_id}";
    }
    return XMLStringer::estring('a', $attrs, $url);
}
开发者ID:himmelex,项目名称:NTW,代码行数:50,代码来源:util.php


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