예제 #1
0
 /** {@inheritdoc} */
 public function render($content)
 {
     $element = $this->getElement();
     $view = $element->getView();
     if (null === $view) {
         return $content;
     }
     $placement = $this->getPlacement();
     $separator = $this->getSeparator();
     $flashvars = array('value' => $element->getValue(), 'elementId' => $element->getId());
     $flashvars = array_merge($flashvars, $element->getAttrib('flashvars'));
     $markup = Curry_Flash::embed(Curry_FLash::SWFOBJECT_DYNAMIC, $element->getAttrib('source'), $element->getAttrib('width'), $element->getAttrib('height'), $element->getAttrib('version'), array_merge($element->getAttrib('options'), array('flashvars' => $flashvars, 'target' => $element->getId() . 'flashTool'))) . '<div id="' . $element->getId() . 'flashTool' . '"></div>';
     switch ($placement) {
         case 'PREPEND':
             $content = $markup . $separator . $content;
             break;
         case 'APPEND':
         default:
             $content = $content . $separator . $markup;
     }
     return $content;
 }
예제 #2
0
파일: Flash.php 프로젝트: varvanin/currycms
 /** {@inheritdoc} */
 public function toTwig()
 {
     $flashvars = array();
     foreach ($this->flashvars as $flashvar) {
         $flashvars[$flashvar['name']] = $flashvar['value'];
     }
     if ($this->module) {
         $moduleTemplate = $this->template ? Curry_Twig_Template::loadTemplate($this->template) : null;
         $flashvars[$this->moduleFlashvar] = $this->module->showFront($moduleTemplate);
     }
     if (in_array("get", $this->addToFlashvars)) {
         Curry_Array::extend($flashvars, $_GET);
     }
     if (in_array("post", $this->addToFlashvars)) {
         Curry_Array::extend($flashvars, $_POST);
     }
     if (in_array("cookie", $this->addToFlashvars)) {
         Curry_Array::extend($flashvars, $_COOKIE);
     }
     $options = array();
     $options['expressInstall'] = $this->expressInstall;
     $options['target'] = $this->target;
     $options['attributes'] = count($this->attributes) ? $this->attributes : null;
     $options['params'] = count($this->params) ? $this->params : null;
     $options['flashvars'] = count($flashvars) ? $flashvars : null;
     $options['alternativeContent'] = $this->alternativeContent;
     $flashContent = Curry_Flash::embed($this->method, $this->flash, $this->width, $this->height, $this->version, $options);
     return array('Source' => $this->flash, 'Target' => $this->target, 'AlternativeContent' => $this->alternativeContent, 'Html' => $flashContent['html'], 'Script' => $flashContent['script']);
 }
예제 #3
0
 /**
  * Get file details.
  *
  * @param array $selected
  * @return array
  */
 public function getFileInfo($selected)
 {
     if (count($selected) == 1) {
         try {
             $path = $selected[0];
             $physical = self::virtualToPhysical($path);
             $public = self::physicalToPublic($physical);
             if (!is_file($physical)) {
                 return null;
             }
             $owner = fileowner($physical);
             if (function_exists('posix_getpwuid')) {
                 $owner = posix_getpwuid($owner);
                 $owner = '<span title="' . $owner['uid'] . '">' . htmlspecialchars($owner['name']) . '</span>';
             }
             $group = filegroup($physical);
             if (function_exists('posix_getgrgid')) {
                 $group = posix_getgrgid($group);
                 $group = '<span title="' . $group['gid'] . '">' . htmlspecialchars($group['name']) . '</span>';
             }
             $fi = array('Name' => '<h2>' . basename($physical) . '</h2>', 'Preview' => '', 'Size' => '<strong>Size: </strong>' . Curry_Util::humanReadableBytes(filesize($physical)), 'Writable' => '<strong>Writable: </strong>' . (self::isWritable($physical) ? 'Yes' : 'No'), 'Permissions' => '<strong>Permissions: </strong>' . Curry_Util::getFilePermissions($physical), 'Owner' => '<strong>Owner: </strong>' . $owner . ' / ' . $group);
             switch (strtolower(pathinfo($physical, PATHINFO_EXTENSION))) {
                 case 'jpg':
                 case 'gif':
                 case 'png':
                 case 'bmp':
                     $image = getimagesize($physical);
                     $fi['Preview'] = '<img src="' . $public . '?' . filemtime($physical) . '" alt="" class="preview" />';
                     if ($image[0] > 240 || $image[1] > 240) {
                         $fi['Preview'] = '<a href="' . $public . '?' . filemtime($physical) . '" target="_blank" class="fullscreen-preview" title="Click to toggle fullscreen">' . $fi['Preview'] . '</a>';
                     }
                     $fi['Dimensions'] = '<strong>Dimension: </strong>' . $image[0] . 'x' . $image[1];
                     if (self::isPhysicalWritable($physical)) {
                         $fi['Actions'] = '<a href="' . url('', array('module', 'view' => 'PixlrEdit', 'image' => $public)) . '" class="dialog" onclick="$(this).data(\'dialog\').width = $(window).width() - 20; $(this).data(\'dialog\').height = $(window).height() - 20;" data-dialog=\'{"width":"90%","height":600,"resizable":false,"draggable":false}\'>Edit with Pixlr</a>';
                     }
                     break;
                 case 'ogg':
                 case 'ogv':
                 case 'mp4':
                 case 'webm':
                     $fi['Preview'] = '<video src="' . $public . '" class="preview" controls />';
                     break;
                 case 'mp3':
                 case 'oga':
                 case 'wav':
                     $fi['Preview'] = '<audio src="' . $public . '" class="preview" controls />';
                     break;
                 case 'swf':
                     $size = getimagesize($physical);
                     $flash = Curry_Flash::embed(Curry_Flash::SWFOBJECT_STATIC, $public, $size[0], $size[1], '9.0.0', array());
                     $fi['Preview'] = $flash['html'];
                     break;
             }
             return $fi;
         } catch (Exception $e) {
             trace_error($e->getMessage());
         }
     } else {
         $totalSize = 0;
         foreach ($selected as $s) {
             $physical = self::virtualToPhysical($s);
             $totalSize += filesize($physical);
         }
         return array('Name' => '<h2>' . count($selected) . ' files</h2>', 'Size' => '<strong>Size: </strong>' . Curry_Util::humanReadableBytes($totalSize));
     }
     return null;
 }