/**
  * @param array $args
  */
 function __construct($args = array())
 {
     if (!isset(self::$_is_php53)) {
         self::$_is_php53 = version_compare(PHP_VERSION, '5.3.0', '>=');
     }
     $this_class = get_class($this);
     if (isset(self::$_instances[$this_class])) {
         $message = __('%s is a singleton class and cannot be instantiated more than once.', 'sidecar');
         Sidecar::show_error($message, self::_get_called_class());
         exit;
     }
     self::$_instances[$this_class] =& $this;
     if (method_exists($this, 'on_load')) {
         $this->on_load($args);
     }
 }
 public function download_zip($entity, $withSidecar = false, $withContents = true)
 {
     // Verify name:
     $entity->entityName = empty($entity->entityName) ? time() : $entity->entityName;
     // Collect article files
     if (DPS_API_VERSION > 1) {
         // If API is Publish bundle an article
         $collectedFiles = $this->collect_article_files($entity);
     } else {
         // otherwise bundle a folio
         $collectedFiles = $this->collect_folio_files($entity);
     }
     /* Combine files into zip format */
     $toZip = array();
     $toZip[$entity->entityName . '.article'] = $this->create_zip($collectedFiles);
     /* Add Sidecar */
     if ($withSidecar) {
         $sidecar = new Sidecar();
         $toZip['sidecar.xml'] = $this->make_file('sidecar', $sidecar->export($entity));
     }
     /* Add Contents */
     if ($withContents) {
         foreach ($entity->contents as $content => $id) {
             $filename = basename($content);
             $toZip["contents/{$content}/{$filename}"] = $this->save_file($filename, $content);
         }
     }
     $bundle = $this->create_zip($toZip);
     header($_SERVER['SERVER_PROTOCOL'] . ' 200 OK');
     header("Content-Type: application/zip");
     header("Content-Transfer-Encoding: Binary");
     header("Content-Length: " . filesize($bundle));
     header("Content-Disposition: attachment; filename=\"" . basename($entity->entityName) . "_" . $entity->entityType . ".zip\"");
     readfile($bundle);
     exit;
 }
Example #3
0
 /**
  * @param $property_name
  * @return bool|string
  */
 function __get($property_name)
 {
     $value = false;
     if (preg_match('#^(.*?_(icon|image|photo))_url$#', $property_name, $match) && $this->has_image($match[1])) {
         $value = call_user_func(array($this, "get_image_url"), $match[1]);
     } else {
         if (preg_match('#^(.*?)_url$#', $property_name, $match) && $this->has_url($match[1])) {
             /**
              * Allows magic property syntax for any registered URL
              * @example: $this->foobar_url calls $this-get_url( 'foobar' )
              * Enables embedding in a HEREDOC or other doublequoted string
              * without requiring an intermediate variable.
              */
             $value = $this->get_url($match[1]);
         } else {
             if (preg_match('#^(.*?)_link$#', $property_name, $match) && $this->has_url($match[1])) {
                 /**
                  * Same kind of this as _url above.
                  */
                 $url = $this->get_url($match[1]);
                 $link_text = $this->get_link_text($match[1]);
                 $class = $this->get_link_class($match[1]);
                 $value = "<a target=\"_blank\"{$class} href=\"{$url}\">{$link_text}</A>";
             } else {
                 Sidecar::show_error('No property named %s on %s class.', $property_name, get_class($this));
             }
         }
     }
     return $value;
 }
Example #4
0
 /**
  * @param $property_name
  * @return bool|string
  */
 function __get($property_name)
 {
     $value = false;
     if (preg_match('#^(.+?)_tab_url$#', $property_name, $match) && $this->has_tab($match[1])) {
         /**
          * Allows magic property syntax for any registered URL
          * @example: $this->foobar_url calls $this-get_url( 'foobar' )
          * Enables embedding in a HEREDOC or other doublequoted string
          * without requiring an intermediate variable.
          */
         $value = call_user_func(array($this, "get_tab_url"), $match[1]);
     } else {
         Sidecar::show_error('No property named %s on %s class.', $property_name, get_class($this));
     }
     return $value;
 }
Example #5
0
 /**
  * Returns the current URL.
  *
  * @return bool
  */
 static function this_url()
 {
     if (!self::$_this_url) {
         $installed_dir = self::installed_dir();
         $requested_path = substr($_SERVER['REQUEST_URI'], strlen($installed_dir));
         self::$_this_url = site_url($requested_path);
     }
     return self::$_this_url;
 }