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


PHP Safe::GetImageSize方法代码示例

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


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

示例1: encode


//.........这里部分代码省略.........
                     $this->Ln(6);
                     $this->SetTextColor(102, 0, 0);
                     $this->SetFontSize(14);
                     $height = 5;
                     break;
                 case '/h1':
                 case '/h2':
                 case '/h3':
                 case '/h4':
                     $this->Ln($height);
                     $this->SetFont('Times', '', 12);
                     $this->SetTextColor(0, 0, 0);
                     $this->SetFontSize(12);
                     $height = 5;
                     break;
                 case 'hr':
                     $this->Ln($height + 2);
                     $this->Line($this->GetX(), $this->GetY(), $this->GetX() + 187, $this->GetY());
                     $this->Ln(3);
                     break;
                 case 'i':
                     $this->SetFont('', 'I');
                     break;
                 case '/i':
                     $this->SetFont('', '');
                     break;
                 case 'img':
                     // only accept JPG and PNG
                     if (preg_match('/src="([^"]+\\.(jpg|jpeg|png))"/i', $attributes, $matches)) {
                         $image = $matches[1];
                         // map on a file
                         $image = preg_replace('/^' . preg_quote($context['url_to_home'] . $context['url_to_root'], '/') . '/', $context['path_to_root'], $image);
                         // include the image only if the file exists
                         if ($attributes = Safe::GetImageSize($image)) {
                             // insert an image at 72 dpi -- the k factor
                             $this->Image($image, $this->GetX(), $this->GetY(), $attributes[0] / $this->k, $attributes[1] / $this->k);
                             // make room for the image
                             $this->y += 3 + $attributes[1] / $this->k;
                         }
                     }
                     break;
                 case 'li':
                     $this->Ln($height);
                     break;
                 case '/li':
                     break;
                 case 'p':
                 case '/p':
                     $this->Ln($height);
                     break;
                 case 'pre':
                     $this->SetFont('Courier', '', 11);
                     $this->SetFontSize(11);
                     $preformatted = TRUE;
                     break;
                 case '/pre':
                     $this->SetFont('Times', '', 12);
                     $this->SetFontSize(12);
                     $preformatted = FALSE;
                     break;
                 case 'strong':
                     $this->SetFont('', 'B');
                     break;
                 case '/strong':
                     $this->SetFont('', '');
                     break;
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:pdf.php

示例2: upload

 /**
  * process one uploaded image
  *
  * @param string file name
  * @param string path to the file
  * @param boolean TRUE to not report on errors
  * @return boolean TRUE on correct processing, FALSE otherwise
  */
 public static function upload($file_name, $file_path, $silent = FALSE)
 {
     global $context, $_REQUEST;
     // we accept only valid images
     if (!($image_information = Safe::GetImageSize($file_path . $file_name))) {
         if (!$silent) {
             Logger::error(sprintf(i18n::s('No image information in %s'), $file_path . $file_name));
         }
         return FALSE;
         // we accept only gif, jpeg and png
     } elseif ($image_information[2] != 1 && $image_information[2] != 2 && $image_information[2] != 3) {
         if (!$silent) {
             Logger::error(sprintf(i18n::s('Rejected file type %s'), $file_name));
         }
         return FALSE;
         // post-upload processing
     } else {
         // create folders
         $_REQUEST['thumbnail_name'] = 'thumbs/' . $file_name;
         // derive a thumbnail image
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_avatar') {
             Image::shrink($file_path . $file_name, $file_path . $_REQUEST['thumbnail_name'], TRUE, TRUE);
         } else {
             Image::shrink($file_path . $file_name, $file_path . $_REQUEST['thumbnail_name'], FALSE, TRUE);
         }
         // always limit the size of avatar images
         if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_avatar') {
             if (Image::adjust($file_path . $file_name, TRUE, 'avatar')) {
                 $_REQUEST['image_size'] = Safe::filesize($file_path . $file_name);
             }
             // always limit the size of icon images
         } elseif (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set_as_icon') {
             if (Image::adjust($file_path . $file_name, TRUE, 'avatar')) {
                 $_REQUEST['image_size'] = Safe::filesize($file_path . $file_name);
             }
             // resize the image where applicable
         } elseif (isset($_REQUEST['automatic_process'])) {
             if (Image::adjust($file_path . $file_name, TRUE, 'standard')) {
                 $_REQUEST['image_size'] = Safe::filesize($file_path . $file_name);
             }
         }
         return TRUE;
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:52,代码来源:image.php

示例3: layout

 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = 'map';
     }
     // put in cache
     $cache_id = Cache::hash('articles/layout_articles_as_carrousel:' . $this->focus) . '.xml';
     // save for one minute
     if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) {
         // content of the slideshow
         $content = '<?xml version="1.0" encoding="utf-8"?><!-- fhShow Carousel 2.0 configuration file Please visit http://www.flshow.net/ -->' . "\n" . '<slide_show>' . "\n" . '	<options>' . "\n" . '		<debug>false</debug>				  <!-- true, false -->' . "\n" . '		<background>transparent</background>	  <!-- #RRGGBB, transparent -->' . "\n" . '		<friction>5</friction>			  <!-- [1,100] -->' . "\n" . '		<fullscreen>false</fullscreen>	  <!-- true, false -->' . "\n" . '		<margins>' . "\n" . '			<top>0</top>								  <!-- [-1000,1000] pixels -->' . "\n" . '			<left>0</left>							  <!-- [-1000,1000] pixels -->' . "\n" . '			<bottom>0</bottom>						  <!-- [-1000,1000] pixels -->' . "\n" . '			<right>0</right>							  <!-- [-1000,1000] pixels -->' . "\n" . '			<horizontal_ratio>20%</horizontal_ratio>	  <!-- [1,50] a photo may occupy at most horizontalRatio percent of the Carousel width -->' . "\n" . '			<vertical_ratio>90%</vertical_ratio>		  <!-- [1,100] a photo may occupy at most verticalRatio percent of the Carousel height -->' . "\n" . '		</margins>' . "\n" . '		<interaction>' . "\n" . '			<rotation>mouse</rotation>			<!-- auto, mouse, keyboard -->' . "\n" . '			<view_point>none</view_point>		   <!-- none, mouse, keyboard -->' . "\n" . '			<speed>15</speed>						<!-- [-360,360] degrees per second -->' . "\n" . '			<default_speed>15</default_speed>				<!-- [-360,360] degrees per second -->' . "\n" . '			<default_view_point>20%</default_view_point>	<!-- [0,100] percentage -->' . "\n" . '			<reset_delay>20</reset_delay>					<!-- [0,600] seconds, 0 means never reset -->' . "\n" . '		</interaction>' . "\n" . '		<far_photos>' . "\n" . '			<size>50%</size>					<!-- [0,100] percentage -->' . "\n" . '			<amount>50%</amount>				<!-- [0,100] percentage -->' . "\n" . '			<blur>10</blur>					<!-- [0,100] amount -->' . "\n" . '			<blur_quality>3</blur_quality>	<!-- [1,3] 1=low - 3=high -->' . "\n" . '		</far_photos>' . "\n" . '		<reflection>' . "\n" . '			<amount>25</amount>	   <!-- [0,1000] pixels -->' . "\n" . '			<blur>2</blur>			<!-- [0,100] blur amount -->' . "\n" . '			<distance>0</distance>	<!-- [-1000,1000] pixels -->' . "\n" . '			<alpha>40%</alpha>		<!-- [0,100] percentage -->' . "\n" . '		</reflection>' . "\n" . '		<titles>' . "\n" . '			<style>font-size: 14px; font-family: Verdana, _serif; color: #000000;</style>' . "\n" . '			<position>above center</position>			  <!-- [above, below] [left,center,right]-->' . "\n" . '			<background>' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/layouts/carrousel_bubble.png</background>	   <!-- image url -->' . "\n" . '			<scale9>35 35 35 35</scale9>				 <!-- [0,1000] pixels -->' . "\n" . '			<padding>8 15 10 15</padding>					<!-- [-1000,1000] pixels -->' . "\n" . '		</titles>' . "\n" . '	</options>' . "\n";
         // get a default image
         if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif';
         } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif';
         } else {
             $default_href = NULL;
         }
         // process all items in the list
         while ($item = SQL::fetch($result)) {
             // get the related overlay
             $overlay = Overlay::load($item, 'article:' . $item['id']);
             // get the anchor
             $anchor = Anchors::get($item['anchor']);
             // this is visual
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $image = $item['icon_url'];
             } elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
                 $image = $item['thumbnail_url'];
             } elseif (is_callable(array($anchor, 'get_bullet_url')) && ($image = $anchor->get_bullet_url())) {
             } elseif ($default_href) {
                 $image = $default_href;
             } else {
                 continue;
             }
             // fix relative path
             if (!preg_match('/^(\\/|http:|https:|ftp:)/', $image)) {
                 $image = $context['url_to_home'] . $context['url_to_root'] . $image;
             }
             // build a title
             if (is_object($overlay)) {
                 $title = Codes::beautify_title($overlay->get_text('title', $item));
             } else {
                 $title = Codes::beautify_title($item['title']);
             }
             // the url to view this item
             $url = Articles::get_permalink($item);
             // add to the list
             $content .= '	<photo>' . "\n" . '		<title>' . $title . '</title>' . "\n" . '		<src>' . $image . '</src>' . "\n" . '		<href>' . $url . '</href>' . "\n" . '		<target>_self</target>' . "\n" . '	</photo>' . "\n";
         }
         // finalize slideshow content
         $content .= '</slide_show>';
         // put in cache
         Safe::file_put_contents($cache_id, $content);
     }
     // allow multiple instances
     static $count;
     if (!isset($count)) {
         $count = 1;
     } else {
         $count++;
     }
     // load the right file
     $text = '<div id="articles_as_carrousel_' . $count . '"></div>' . "\n";
     Page::insert_script('swfobject.embedSWF("' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/carrousel.swf",' . "\n" . '"articles_as_carrousel_' . $count . '",' . "\n" . '"100%",' . "\n" . '"150",' . "\n" . '"9.0.0",' . "\n" . 'false,' . "\n" . '{xmlfile:"' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", loaderColor:"0x666666"},' . "\n" . '{wmode: "transparent"},' . "\n" . '{});' . "\n");
     // end of processing
     SQL::free($result);
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:86,代码来源:layout_articles_as_carrousel.php

示例4: get_img

 /**
  * get a <img> element
  *
  * @param the type ('suggestion', etc.')
  * @return a suitable HTML element
  *
  * @see skins/skin_skeleton.php
  */
 public static function get_img($type)
 {
     global $context;
     switch ($type) {
         // approval
         case 'approval':
             // use skin declaration if any
             if (!defined('APPROVAL_IMG')) {
                 // else use default image file
                 $file = 'skins/_reference/comments/yes.gif';
                 if ($size = Safe::GetImageSize($context['path_to_root'] . $file)) {
                     define('APPROVAL_IMG', '<img src="' . $context['url_to_root'] . $file . '" ' . $size[3] . ' alt="" />');
                 } else {
                     define('APPROVAL_IMG', '');
                 }
             }
             return APPROVAL_IMG;
             // it's worth the reading
         // it's worth the reading
         case 'attention':
         case 'default':
         default:
             // use skin declaration if any
             if (!defined('ATTENTION_IMG')) {
                 // else use default image file
                 $file = 'skins/_reference/comments/attention.gif';
                 if ($size = Safe::GetImageSize($context['path_to_root'] . $file)) {
                     define('ATTENTION_IMG', '<img src="' . $context['url_to_root'] . $file . '" ' . $size[3] . ' alt="" />');
                 } else {
                     define('ATTENTION_IMG', '');
                 }
             }
             return ATTENTION_IMG;
             // denial
         // denial
         case 'denial':
             // use skin declaration if any
             if (!defined('DENIAL_IMG')) {
                 // else use default image file
                 $file = 'skins/_reference/comments/no.gif';
                 if ($size = Safe::GetImageSize($context['path_to_root'] . $file)) {
                     define('DENIAL_IMG', '<img src="' . $context['url_to_root'] . $file . '" ' . $size[3] . ' alt="" />');
                 } else {
                     define('DENIAL_IMG', '');
                 }
             }
             return DENIAL_IMG;
             // job has been completed
         // job has been completed
         case 'done':
             // use skin declaration if any
             if (!defined('DONE_IMG')) {
                 // else use default image file
                 $file = 'skins/_reference/comments/done.gif';
                 if ($size = Safe::GetImageSize($context['path_to_root'] . $file)) {
                     define('DONE_IMG', '<img src="' . $context['url_to_root'] . $file . '" ' . $size[3] . ' alt="" />');
                 } else {
                     define('DONE_IMG', '');
                 }
             }
             return DONE_IMG;
             // to submit a new suggestion
         // to submit a new suggestion
         case 'idea':
         case 'suggestion':
             //-- legacy keyword
             // use skin declaration if any
             if (!defined('IDEA_IMG')) {
                 // else use default image file
                 $file = 'skins/_reference/comments/idea.gif';
                 if ($size = Safe::GetImageSize($context['path_to_root'] . $file)) {
                     define('IDEA_IMG', '<img src="' . $context['url_to_root'] . $file . '" ' . $size[3] . ' alt="" />');
                 } else {
                     define('IDEA_IMG', '');
                 }
             }
             return IDEA_IMG;
             // manual or automatic notification
         // manual or automatic notification
         case 'information':
         case 'notification':
             // use skin declaration if any
             if (!defined('INFORMATION_IMG')) {
                 // else use default image file
                 $file = 'skins/_reference/comments/information.gif';
                 if ($size = Safe::GetImageSize($context['path_to_root'] . $file)) {
                     define('INFORMATION_IMG', '<img src="' . $context['url_to_root'] . $file . '" ' . $size[3] . ' alt="" />');
                 } else {
                     define('INFORMATION_IMG', '');
                 }
             }
             return INFORMATION_IMG;
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:comments.php

示例5: submit_image

 /**
  * create a referenced image
  *
  * @param array of entity attributes (e.g., 'Content-Disposition')
  * @param string image actual content
  * @param array poster attributes
  * @param string the target anchor (e.g., 'article:123')
  * @param string reference of the object to be extended, if any
  * @return string reference to the created object, or NULL
  */
 public static function submit_image($entity_headers, $content, $user, $anchor, $target = NULL)
 {
     global $context;
     // retrieve queue parameters
     list($server, $account, $password, $allowed, $match, $section, $options, $hooks, $prefix, $suffix) = $context['mail_queue'];
     // locate content-disposition
     foreach ($entity_headers as $header) {
         if (preg_match('/Content-Disposition/i', $header['name'])) {
             $content_disposition = $header['value'];
             break;
         }
     }
     // find file name in content-disposition
     $file_name = '';
     if ($content_disposition && preg_match('/filename="*([a-zA-Z0-9\'\\(\\)\\+_,-\\.\\/:=\\? ]+)"*\\s*/i', $content_disposition, $matches)) {
         $file_name = $matches[1];
     }
     // as an alternative, look in content-type
     if (!$file_name) {
         // locate content-type
         foreach ($entity_headers as $header) {
             if (preg_match('/Content-Type/i', $header['name'])) {
                 $content_type = $header['value'];
                 break;
             }
         }
         // find file name in content-type
         if ($content_type && preg_match('/name="*([a-zA-Z0-9\'\\(\\)\\+_,-\\.\\/:=\\? ]+)"*\\s*/i', $content_type, $matches)) {
             $file_name = $matches[1];
         }
     }
     // as an alternative, look in content-description
     if (!$file_name) {
         // locate content-description
         foreach ($entity_headers as $header) {
             if (preg_match('/Content-Description/i', $header['name'])) {
                 $content_description = $header['value'];
                 break;
             }
         }
         // find file name in content-description
         $file_name = $content_description;
     }
     // sanity check
     if (!$file_name) {
         Logger::remember('agents/messages.php: No file name to use for submitted image');
         return NULL;
     }
     // file size
     $file_size = strlen($content);
     // sanity check
     if ($file_size < 7) {
         Logger::remember('agents/messages.php: Short image skipped', $file_name);
         return NULL;
     }
     // sanity check
     if (!$anchor) {
         Logger::remember('agents/messages.php: No anchor to use for submitted image', $file_name);
         return NULL;
     }
     // get anchor data -- this is a mutable object
     $host = Anchors::get($anchor, TRUE);
     if (!is_object($host)) {
         Logger::remember('agents/messages.php: Unknown anchor ' . $anchor, $file_name);
         return NULL;
     }
     // create target folders
     $file_path = Files::get_path($anchor, 'images');
     if (!Safe::make_path($file_path)) {
         Logger::remember('agents/messages.php: Impossible to create ' . $file_path);
         return NULL;
     }
     if (!Safe::make_path($file_path . '/thumbs')) {
         Logger::remember('agents/messages.php: Impossible to create ' . $file_path . '/thumbs');
         return NULL;
     }
     $file_path = $context['path_to_root'] . $file_path . '/';
     // save the entity in the file system
     if (!($file = Safe::fopen($file_path . $file_name, 'wb'))) {
         Logger::remember('agents/messages.php: Impossible to open ' . $file_path . $file_name);
         return NULL;
     }
     if (fwrite($file, $content) === FALSE) {
         Logger::remember('agents/messages.php: Impossible to write to ' . $file_path . $file_name);
         return NULL;
     }
     fclose($file);
     // get image information
     if (!($image_information = Safe::GetImageSize($file_path . $file_name))) {
         Safe::unlink($file_path . $file_name);
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:messages.php

示例6: define_img

 /**
  * define a constant img tag
  *
  * mainly called from initialize(), in skins/skin_skeleton.php, and as Skin::initialize()
  *
  * @param string constant name, in upper case
  * @param string file name for this image
  * @param string to be used if the file does not exists
  * @param string to be displayed in textual browsers
  * @param string options to be integrated into the img tag, if any
  */
 public static function define_img($name, $file, $default = '', $alternate = '', $options = '')
 {
     global $context;
     // sanity check
     if (defined($name)) {
         return;
     }
     // make an absolute path to image, in case of export (freemind, etc.)
     if ($size = Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/' . $file)) {
         define($name, ' <img src="' . $context['url_to_master'] . $context['url_to_root'] . $context['skin'] . '/' . $file . '" ' . $size[3] . ' alt="' . $alternate . '" ' . $options . ' />');
     } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/' . $file)) {
         define($name, ' <img src="' . $context['url_to_master'] . $context['url_to_root'] . 'skins/_reference/' . $file . '" ' . $size[3] . ' alt="' . $alternate . '" ' . $options . ' />');
     } else {
         define($name, $default);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:27,代码来源:skin_skeleton.php

示例7: preview

 /**
  * give a preview of file rendering
  * used after ajax uploading in forms
  * 
  * @param string $url string where is the file
  * @param string $input_name the input that what used to upload
  */
 public static function preview($url, $input_name)
 {
     global $context;
     // get file ext.
     $ext = pathinfo($url, PATHINFO_EXTENSION);
     $basename = basename($url);
     // at least show file's name
     $preview = $basename;
     // destroy link, put it where you want
     $destroy = '<a class="yc-upload-destroy" data-del="' . $input_name . '" href="javascript:void(0);" title="' . i18n::s('Delete') . '" onclick="Yacs.uploadDestroy($(this).data(\'del\'),$(this))" >x</a>' . "\n";
     // file is a image
     if (Files::is_image($url) && ($image_information = Safe::GetImageSize($url))) {
         // make a temp thumb name
         $thumb = uniqid() . '.' . $ext;
         $thumbpath = $context['path_to_root'] . UPLOAD_PATH . $thumb;
         $thumburl = $context['url_to_root'] . UPLOAD_PATH . $thumb;
         // make a thumb
         Image::shrink($url, $thumbpath, true);
         // build image
         $preview = Skin::build_image('left', $thumburl, '') . '<span style="line-height:34px"> ' . $basename . '</span>' . "\n" . $destroy;
     } else {
         // file is a reconnized audio format
         switch ($ext) {
             case 'mp3':
             case 'm4a':
             case 'aac':
             case 'oog':
                 // audio file
                 $audio_url = $context['url_to_root'] . UPLOAD_PATH . $basename;
                 $preview .= $destroy . BR . Skin::build_audioplayer($audio_url);
                 break;
             default:
                 $icon = Skin::build_image('inline', $context['url_to_master'] . $context['url_to_root'] . Files::get_icon_url($basename), $basename);
                 $preview = $icon . $preview . '&nbsp;' . $destroy;
                 break;
         }
     }
     // add separator
     $preview .= '<hr class="clear" />' . "\n";
     // wrap
     $preview = '<div class="yc-preview">' . $preview . '</div>';
     return $preview;
 }
开发者ID:rair,项目名称:yacs,代码行数:50,代码来源:files.php

示例8: explode_callback

 function explode_callback($name)
 {
     global $context;
     // reject all files put in sub-folders
     $file_path = Files::get_path($_REQUEST['anchor'], 'images');
     if (($path = substr($name, strlen($file_path . '/'))) && strpos($path, '/') !== FALSE) {
         Safe::unlink($name);
     } elseif (!($attributes = Safe::GetImageSize($name))) {
         Safe::unlink($name);
     } elseif ($attributes[0] > 5000 || $attributes[1] > 5000) {
         Safe::unlink($name);
     }
 }
开发者ID:rair,项目名称:yacs,代码行数:13,代码来源:edit.php

示例9: layout

 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // load the SIMILE Timeline javascript library in shared/global.php
     $context['javascript']['timeline'] = TRUE;
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = 'default';
     }
     // put in cache
     $cache_id = Cache::hash('articles/layout_articles_as_simile:' . $this->focus) . '.xml';
     // save for one minute
     if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) {
         // content of the slideshow
         $content = '<?xml version="1.0" encoding="utf-8"?>' . "\n" . '<data>' . "\n";
         // get a default image
         if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif';
         } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) {
             $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif';
         } else {
             $default_href = NULL;
         }
         // process all items in the list
         while ($item = SQL::fetch($result)) {
             // get the related overlay
             $overlay = Overlay::load($item, 'article:' . $item['id']);
             // get the anchor
             $anchor = Anchors::get($item['anchor']);
             // start
             if ($item['publish_date'] > $item['create_date']) {
                 $first = Skin::build_date($item['publish_date'], 'plain');
             } else {
                 $first = Skin::build_date($item['create_date'], 'plain');
             }
             // end
             $last = Skin::build_date($item['edit_date'], 'plain');
             if ($last != $first) {
                 $last = ' end="' . $last . '"';
             } else {
                 $last = '';
             }
             // build a title
             if (is_object($overlay)) {
                 $title = Codes::beautify_title($overlay->get_text('title', $item));
             } else {
                 $title = Codes::beautify_title($item['title']);
             }
             // the url to view this item
             $url = str_replace('&', '&amp;', Articles::get_permalink($item));
             // this is visual
             if (isset($item['icon_url']) && $item['icon_url']) {
                 $image = $item['icon_url'];
             } elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
                 $image = $item['thumbnail_url'];
             } else {
                 $image = '';
             }
             // fix relative path
             if ($image && !preg_match('/^(\\/|http:|https:|ftp:)/', $image)) {
                 $image = $context['url_to_root'] . $image;
             }
             if ($image) {
                 $image = ' image="' . $image . '"';
             }
             // introduction
             $introduction = '';
             if (is_object($overlay)) {
                 $introduction = $overlay->get_text('introduction', $item);
             } else {
                 $introduction = $item['introduction'];
             }
             // insert overlay data, if any
             if (is_object($overlay) && ($data = $overlay->get_text('list', $item))) {
                 if ($introduction) {
                     $introduction .= BR;
                 }
                 $introduction .= $data;
             }
             // ampersands kill SIMILE Timeline
             if ($introduction) {
                 $introduction = encode_field(str_replace(array('&nbsp;', '&'), ' ', Codes::beautify($introduction)));
             }
             // details
             $details = array();
             // info on related comments
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_simile.php

示例10: elseif

    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    // only available to site associates
} elseif (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // provide requested data
} else {
    // loads feeding parameters
    Safe::load('parameters/feeds.include.php');
    // set preamble strings
    $title = sprintf(i18n::s('Event log at %s'), strip_tags($context['site_name']));
    // provide shortcuts for this site
    $splash = sprintf(i18n::s('Most recent events at %s'), $context['host_name']);
    // the preamble
    $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rss version="2.0">' . "\n" . '<channel>' . "\n" . '	<title>' . encode_field($title) . '</title>' . "\n" . '	<link>' . $context['url_to_home'] . $context['url_to_root'] . 'agents/</link>' . "\n" . '	<description><![CDATA[ ' . $splash . ' ]]></description>' . "\n";
    if (isset($context['powered_by_image']) && $context['powered_by_image'] && ($size = Safe::GetImageSize($context['path_to_root'] . $context['powered_by_image']))) {
        $text .= '	<image>' . "\n" . '		<url>' . $context['url_to_home'] . $context['url_to_root'] . $context['powered_by_image'] . '</url>' . "\n" . '		<width>' . $size[0] . '</width>' . "\n" . '		<height>' . $size[1] . '</height>' . "\n" . '		<title>' . encode_field($title) . '</title>' . "\n" . '		<link>' . $context['url_to_home'] . $context['url_to_root'] . 'agents/</link>' . "\n" . '	</image>' . "\n";
    }
    if ($context['preferred_language']) {
        $text .= '	<language>' . encode_field($context['preferred_language']) . '</language>' . "\n";
    }
    $text .= '	<lastBuildDate>' . gmdate('D, d M Y H:i:s') . ' GMT</lastBuildDate>' . "\n" . '	<generator>yacs</generator>' . "\n" . '	<docs>http://blogs.law.harvard.edu/tech/rss</docs>' . "\n" . '	<ttl>5</ttl>' . "\n";
    // list last events
    $events = Logger::get_tail(50, 'all');
    if (is_array($events)) {
        // the actual list of events
        foreach ($events as $event) {
            list($stamp, $surfer, $script, $label, $description) = $event;
            // formatting patterns
            $search = array("|\r\n|", "|<br\\s*/>\n+|i", "|\n\n+[ \t]*-\\s+|i", "|\n[ \t]*-\\s+|i", "|\n\n+[ \t]*\\.\\s+|i", "|\n[ \t]*\\.\\s+|i", "|\n\n+[ \t]*\\*\\s+|i", "|\n[ \t]*\\*\\s+|i", "|\n\n+[ \t]*¤\\s+|i", "|\n[ \t]*¤\\s+|i", "|\n\n+[ \t]*\\•\\s+|i", "|\n[ \t]*\\•\\s+|i", "/\n[ \t]*(From|To|cc|bcc|Subject|Date):(\\s*)/i", "|\n[ \t]*>(\\s*)|i", "|\n[ \t]*\\|(\\s*)|i", "#([\n\t ])([a-z]+?)://([^, <>{}\n\r]+)#is", "#^([a-z]+?)://([^, <>{}\n\r]+)#is", "#([\n\t ])www\\.([a-z0-9\\-]+)\\.([a-z0-9\\-.\\~]+)((?:/[^,< \n\r]*)?)#is", "#([\n\t ])([a-z0-9\\-_.]+?)@([^,< \\.\n\r]+\\.[^,< \n\r]+)#is", "|\n\n|i");
            $replace = array("\n", BR, BR . BR . "- ", BR . "- ", BR . BR . "- ", BR . "- ", BR . BR . "- ", BR . "- ", BR . BR . "- ", BR . "- ", BR . BR . "• ", BR . "• ", BR . "\$1:\$2", BR . ">\$1", BR . "|\$1", "\$1<a href=\"\$2://\$3\">\$2://\$3</a>", "<a href=\"\$1://\$2\">\$1://\$2</a>", "\$1<a href=\"http://www.\$2.\$3\$4\">http://www.\$2.\$3\$4</a>", "\$1<a href=\"mailto:\$2@\$3\">\$2@\$3</a>", BR . BR);
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:feed.php

示例11: encode

 /**
  * encode PHP data into RSS
  *
  * Accept following values:
  * - $values['channel']['title'] is a string
  * - $values['channel']['link'] is a string
  * - $values['channel']['description'] is a string
  * - $values['channel']['image'] is a string to a channel image, if any
  * - $values['items'] is an array of $url => array($time, $title, $author, $section, $image, $introduction, $description, $comments, $trackback, $comment_post, $comment_rss)
  *
  * @param mixed the parameter to encode
  * @return some XML
  */
 public static function encode(&$values)
 {
     global $context;
     // ensure we have a channel title
     if (isset($values['channel']['title']) && $values['channel']['title']) {
         $channel_title = $values['channel']['title'];
     } elseif (isset($context['server_title']) && $context['server_title']) {
         $channel_title = $context['server_title'];
     } else {
         $channel_title = $context['host_name'];
     }
     // ensure we have a channel link
     if (isset($values['channel']['link']) && $values['channel']['link']) {
         $channel_link = $values['channel']['link'];
     } else {
         $channel_link = $context['url_to_home'] . $context['url_to_root'];
     }
     // allowed HTML in description
     $allowed = '<a><b><blockquote><form><hr><input><li><ol><p><strong><u><ul>';
     // the preamble
     $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rss version="2.0" ' . "\n" . '	xmlns:atom="http://www.w3.org/2005/Atom" ' . "\n" . '	xmlns:content="http://purl.org/rss/1.0/modules/content/" ' . "\n" . '	xmlns:dc="http://purl.org/dc/elements/1.1/" ' . "\n" . '	xmlns:georss="http://www.georss.org/georss" ' . "\n" . '	xmlns:icbm="http://postneo.com/icbm" ' . "\n" . '	xmlns:slash="http://purl.org/rss/1.0/modules/slash/" ' . "\n" . '	xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" ' . "\n" . '	xmlns:wfw="http://wellformedweb.org/CommentAPI/" >' . "\n" . "\n" . '<channel>' . "\n" . '	<title>' . rss_codec::clean($channel_title) . '</title>' . "\n" . '	<link>' . encode_link($channel_link) . '</link>' . "\n" . '	<atom:link href="' . encode_link($context['self_url']) . '"  rel="self" type="application/rss+xml" />' . "\n" . '	<description>' . rss_codec::clean($values['channel']['description'], $allowed) . '</description>' . "\n";
     if (isset($values['channel']['image']) && $values['channel']['image'] && ($size = Safe::GetImageSize($values['channel']['image']))) {
         $text .= '	<image>' . "\n" . '		<url>' . encode_link($context['url_to_home'] . $context['url_to_root'] . $values['channel']['image']) . '</url>' . "\n" . '		<width>' . $size[0] . '</width>' . "\n" . '		<height>' . $size[1] . '</height>' . "\n" . '		<title>' . rss_codec::clean($channel_title) . '</title>' . "\n" . '		<link>' . encode_link($channel_link) . '</link>' . "\n" . '	</image>' . "\n";
     }
     if (isset($context['preferred_language']) && $context['preferred_language']) {
         $text .= '	<language>' . $context['preferred_language'] . '</language>' . "\n";
     }
     if (isset($context['site_copyright']) && $context['site_copyright']) {
         $text .= '	<copyright>' . rss_codec::clean($context['site_copyright']) . '</copyright>' . "\n";
     }
     if (isset($context['site_email']) && $context['site_email']) {
         $text .= '	<managingEditor>' . rss_codec::clean($context['site_email']) . '</managingEditor>' . "\n";
     }
     if (isset($context['webmaster_address']) && $context['webmaster_address']) {
         $text .= '	<webMaster>' . rss_codec::clean($context['site_email']) . '</webMaster>' . "\n";
     }
     // encode icbm position
     if (isset($context['site_position']) && $context['site_position']) {
         list($latitude, $longitude) = preg_split('/[ ,\\t]+/', $context['site_position']);
         $text .= '	<icbm:latitude>' . rss_codec::clean($latitude) . '</icbm:latitude>' . "\n";
         $text .= '	<icbm:longitude>' . rss_codec::clean($longitude) . '</icbm:longitude>' . "\n";
         $text .= '	<georss:point>' . str_replace(',', ' ', $context['site_position']) . '</georss:point>' . "\n";
     }
     $text .= '	<lastBuildDate>' . gmdate('D, d M Y H:i:s') . ' GMT</lastBuildDate>' . "\n" . '	<generator>yacs</generator>' . "\n" . '	<docs>http://blogs.law.harvard.edu/tech/rss</docs>' . "\n";
     if (isset($context['time_to_live']) && $context['time_to_live'] > 0) {
         $text .= '	<ttl>' . $context['time_to_live'] . '</ttl>' . "\n";
     } else {
         $text .= '	<ttl>70</ttl>' . "\n";
     }
     // process rows, if any
     if (isset($values['items']) && is_array($values['items'])) {
         // for each item
         foreach ($values['items'] as $url => $attributes) {
             $time = $attributes[0];
             $title = $attributes[1];
             $author = $attributes[2];
             $section = $attributes[3];
             $image = $attributes[4];
             $introduction = $attributes[5];
             $description = $attributes[6];
             $extensions = $attributes[7];
             // output one story
             $text .= "\n" . ' <item>' . "\n";
             if ($title) {
                 $text .= '		<title>' . rss_codec::clean($title) . "</title>\n";
             }
             if ($url) {
                 $text .= '		<link>' . encode_link($url) . "</link>\n" . '		<guid isPermaLink="true">' . encode_link($url) . "</guid>\n";
             }
             if ($introduction) {
                 $text .= '		<description>' . rss_codec::clean($introduction) . "</description>\n";
             } elseif ($description) {
                 $text .= '		<description>' . rss_codec::clean($description) . "</description>\n";
             }
             // use unicode entities, and escape & chars that are not part of an entity
             if ($description) {
                 $text .= '		<content:encoded><![CDATA[ ' . str_replace(']]>', ']]]]><![CDATA[>', $description) . " ]]></content:encoded>\n";
             }
             // do not express mail addresses, but only creator name, which is between ()
             if (preg_match('/\\((.*?)\\)/', $author, $matches)) {
                 $text .= '		<dc:creator>' . rss_codec::clean($matches[1]) . "</dc:creator>\n";
             }
             // do not put any attribute, it would kill FeedReader
             if ($section) {
                 $text .= '		<category>' . encode_field(strip_tags($section)) . "</category>\n";
             }
             if (intval($time)) {
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:rss_codec.php

示例12: get_text_to_view

 /**
  * fully describe a poll in its main page
  *
  * This also features a voting form, to let people vote from permalinks.
  *
  * @link http://www.slashdot.org/ Slashdot has been copied for the layout, and for the bar images as well
  *
  * @param array attributes of the containing page
  * @param boolean TRUE if votes are enabled, FALSE otherwise
  * @return some HTML to be inserted into the resulting page
  */
 function get_text_to_view($host = NULL, $enable_votes = TRUE)
 {
     global $context;
     if (!isset($this->attributes['answers'])) {
         return '';
     }
     if (!is_array($this->attributes['answers'])) {
         return '';
     }
     // use images either from the skin, or from the polls directory
     if ($size = Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/images/poll_left.gif')) {
         $left_img = '<img src="' . $context['url_to_root'] . $context['skin'] . '/images/poll_left.gif" ' . $size[3] . ' alt="" />';
     } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'overlays/polls/bar_left.gif')) {
         $left_img = '<img src="' . $context['url_to_root'] . 'overlays/polls/bar_left.gif" ' . $size[3] . ' alt="" />';
     }
     if ($size = Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/images/poll_main.gif')) {
         $main_img = '<img src="' . $context['url_to_root'] . $context['skin'] . '/images/poll_main.gif" ' . $size[3] . ' alt="" />';
     } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'overlays/polls/bar_main.gif')) {
         $main_img = '<img src="' . $context['url_to_root'] . 'overlays/polls/bar_main.gif" ' . $size[3] . ' alt="" />';
     }
     if ($size = Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/images/poll_right.gif')) {
         $right_img = '<img src="' . $context['url_to_root'] . $context['skin'] . '/images/poll_right.gif" ' . $size[3] . ' alt="" />';
     } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'overlays/polls/bar_right.gif')) {
         $right_img = '<img src="' . $context['url_to_root'] . 'overlays/polls/bar_right.gif" ' . $size[3] . ' alt="" />';
     }
     // compute totals
     $total = 0;
     $maximum = 0;
     foreach ($this->attributes['answers'] as $answer) {
         list($label, $count) = $answer;
         $total += $count;
         $maximum = max($maximum, strlen($label));
     }
     // empty form when votes are disallowed
     $text = '<form method="post" action="' . $context['url_to_root'] . 'overlays/polls/vote.php">';
     // layout poll elements
     $text .= '<dl class="poll">';
     // one row per answer
     $index = 1;
     foreach ($this->attributes['answers'] as $answer) {
         list($label, $count) = $answer;
         $text .= '<dt>';
         if ($enable_votes) {
             $text .= '<input type="radio" name="vote" value="' . $index++ . '" /> ';
         }
         $text .= $label . '</dt>' . "\n";
         $text .= '<dd>';
         if ($total > 0) {
             $size = (int) ($count * 350 / $total) + 2;
         } else {
             $size = 2;
         }
         $text .= $left_img . preg_replace('/width=".+?"/i', 'width="' . $size . '"', $main_img) . $right_img . ' ' . number_format($count);
         if ($total > 0) {
             $text .= ' / <b>' . (int) ($count * 100 / $total) . '%</b>';
         }
         $text .= '<br style="clear: left;" /></dd>' . "\n";
     }
     $text .= '</dl>' . "\n";
     // votes are allowed
     if ($enable_votes) {
         $text .= '<p>';
         // a button to vote
         $text .= Skin::build_submit_button(i18n::s('Cast your vote'));
         // summarize votes
         if ($total > 1) {
             $text .= ' ' . sprintf(i18n::s('%d votes up to now'), $total);
         }
         $text .= '</p>' . "\n";
     }
     // end of the form
     $text .= '<input type="hidden" name="id" value="' . $host['id'] . '" />' . '</form>' . "\n";
     return $text;
 }
开发者ID:rair,项目名称:yacs,代码行数:85,代码来源:poll.php


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