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


PHP Attachments::type方法代码示例

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


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

示例1: get_banner

function get_banner($banner_slug, $echo = true, $url_and_link = false)
{
    $banner_id = get_post_id_by_slug($banner_slug, 'banners');
    $banners = new Attachments('banner_attachments', $banner_id);
    $output = "";
    if ($banners->exist()) {
        $i = 0;
        //пишем всю эту муть.. там в Attachments::()->OneSort();
        $o = $banners->OneSort();
        if (empty($o)) {
            $o = 0;
        }
        //ты втираешь мне какуюто Дичь!?
        if ($banners->total() > 1) {
            if (!session_id()) {
                session_start();
            }
            if (!isset($_SESSION[$banner_slug])) {
                $_SESSION[$banner_slug] = $o;
                $_SESSION[start] = true;
            } else {
                $_SESSION[start] = false;
            }
            $i = intval($_SESSION[$banner_slug]);
            //извольте?!?
            if ($_SESSION[start]) {
                $i = $i;
            } else {
                if ($i < $banners->total() - 1) {
                    $_SESSION[$banner_slug] = ++$i;
                } else {
                    $_SESSION[$banner_slug] = $i = 0;
                }
            }
        }
        if ($banners->get_single($i)) {
            if ($url_and_link) {
                return array('url' => $banners->url($i), 'link' => $banners->field('link_url', $i));
            }
            if ($banners->type($i) == 'image') {
                $b_url = $banners->field('link_url', $i);
                if (!empty($b_url)) {
                    $output .= '<noindex><a rel="nofollow" href="' . $b_url . '" target="_blank">';
                }
                $output .= '<img src="' . $banners->url($i) . '" width="100%" />';
                if (!empty($b_url)) {
                    $output .= '</a></noindex>';
                }
            }
            if ($banners->type($i) == 'application') {
                $hb = explode("x", $banner_slug);
                $parent_id = $banner_slug . '_' . $banners->id($i);
                $output .= '<div id="' . $parent_id . '"><script type="text/javascript">';
                $output .= 'swfobject.embedSWF("' . $banners->url($i) . '", "' . $parent_id . '", "100%", "' . $hb[1] . '", "10.0.0", "install flash player", null, {menu: "false", wmode: "transparent", scale:"default"}, null);';
                $output .= '</script></div>';
            }
        }
    } else {
        if ($echo) {
            echo $output;
        } else {
            return false;
        }
    }
    if ($echo) {
        echo $output;
    } else {
        return $output;
    }
}
开发者ID:TimurMG,项目名称:mg-red,代码行数:70,代码来源:functions.php

示例2: get_attachments_array

function get_attachments_array($name, $srcSize = 'full')
{
    $return = array();
    $attachments = new Attachments($name);
    if ($attachments->exist()) {
        $i = 0;
        while ($attachments->get()) {
            $return[$i]['id'] = $attachments->id();
            $return[$i]['type'] = $attachments->type();
            $return[$i]['subtype'] = $attachments->subtype();
            $return[$i]['url'] = $attachments->url();
            $return[$i]['thumbnail'] = $attachments->image('thumbnail');
            $return[$i]['srcfull'] = $attachments->src('full');
            $return[$i]['src'] = $attachments->src($srcSize);
            $return[$i]['filesize'] = $attachments->filesize();
            $return[$i]['title'] = $attachments->field('title');
            $return[$i]['caption'] = $attachments->field('caption');
            $i++;
        }
    }
    return $return;
}
开发者ID:santikrass,项目名称:apache,代码行数:22,代码来源:functions.php


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