Пример #1
0
 function onSubmit($vals)
 {
     if (intl_lang() == intl_default_lang()) {
         $ps1 = new PropertySet('sitegallery', 'album_title');
         $ps2 = new PropertySet('sitegallery', 'album_description');
         $ps3 = new PropertySet('sitegallery', 'album_date');
     } else {
         $ps1 = new PropertySet('sitegallery', 'album_title_' . intl_lang());
         $ps2 = new PropertySet('sitegallery', 'album_description_' . intl_lang());
         $ps3 = new PropertySet('sitegallery', 'album_date');
     }
     $ps1->set($vals['album'], $vals['title']);
     $ps2->set($vals['album'], $vals['description']);
     $ps3->set($vals['album'], $vals['date']);
     if (appconf('page_alias')) {
         header('Location: ' . site_prefix() . '/index/' . appconf('page_alias'));
         exit;
     }
     header('Location: ' . site_prefix() . '/index/sitegallery-app');
     exit;
 }
Пример #2
0
 /** Testing Countable **/
 public function testCount()
 {
     $this->assertEquals(count(self::$properties), $this->props->count());
 }
Пример #3
0
 public function testAliasing()
 {
 	$name = 'NAME';
 	$alias = 'n';
 	$propertySet = new PropertySet();
 	$propertySet[$name] = $this->getMockProperty();
 	$propertySet->setStorageName($name, $alias);
 	$this->assertSame($alias, $propertySet->getStorageName($name));
 }
Пример #4
0
 /**
  * Fetches the actual value for this widget.
  * 
  * @access	public
  * @param	object	$cgi
  * @return	string
  * 
  */
 function getValue($cgi = '')
 {
     if (is_object($cgi)) {
         if (!isset($cgi->{$this->name})) {
             $value = '';
         } elseif (is_array($cgi->{$this->name})) {
             $value = join(',', $cgi->{$this->name});
         } else {
             $value = $cgi->{$this->name};
         }
     } else {
         $value = $this->data_value;
     }
     loader_import('saf.Database.PropertySet');
     $ps = new PropertySet('mailform', 'snippet');
     $key = md5($value);
     $ps->set($key, $value);
     return $key;
 }
Пример #5
0
 /**
  * Fetches a remote XML document and returns an object structure
  * parsed by SloppyDOM.  Returns false if there is a parsing
  * error, and sets the $error property with the error message.
  * $expires can be set to either 'auto' (the default), which
  * tries to discover the cache duration based on the
  * syn:updatePeriod and syn:updateFrequency values in the
  * feed itself, and defaults to 1 hour (3600 seconds) if they
  * are not present.  If $expires is set to a number, that is
  * used as the number of seconds to cache the feed for.
  *
  * @access	public
  * @param	string
  * @param	mixed
  * @return	object
  */
 function &fetch($url, $expires = 'auto')
 {
     $ps = new PropertySet('rss_fetch', 'source');
     $doc = false;
     $res = $ps->get($url);
     if ($res) {
         $doc = unserialize($res);
         if ($doc->_expires < time()) {
             $doc = false;
         }
     }
     if (!$doc) {
         if (extension_loaded('curl')) {
             $ch = curl_init();
             curl_setopt($ch, CURLOPT_URL, $url);
             curl_setopt($ch, CURLOPT_MAXREDIRS, 3);
             curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
             curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
             curl_setopt($ch, CURLOPT_VERBOSE, 0);
             curl_setopt($ch, CURLOPT_HEADER, 0);
             curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10);
             $rssfeed = curl_exec($ch);
             if (!$rssfeed) {
                 $this->error = 'RSS source not found: ' . curl_error($ch) . ' (' . curl_errno($ch) . ')';
                 curl_close($ch);
                 return false;
             }
             curl_close($ch);
         } else {
             $rssfeed = @file($url);
             if (!is_array($rssfeed) || count($rssfeed) <= 0) {
                 $this->error = 'RSS source not found';
                 return false;
             }
             $rssfeed = @join('', $rssfeed);
         }
         $sloppy = new SloppyDOM();
         $doc = $sloppy->parse($rssfeed);
         if (!$doc) {
             $this->error = $sloppy->error;
             return false;
         }
         $root = $doc->root->name;
         $ns = false;
         foreach (array_keys($doc->root->attributes) as $k) {
             if ($doc->root->attributes[$k]->value == 'http://purl.org/rss/1.0/modules/syndication/') {
                 $ns = str_replace('xmlns:', '', $doc->root->attributes[$k]->name);
             }
         }
         if (!$ns) {
             $ns = 'syn';
         }
         // auto tries to auto-discover the cache expiration time
         if ($expires == 'auto') {
             $node =& $doc->query($root . '/channel/' . $ns . ':updatePeriod');
             if (is_object($node)) {
                 switch ($node->content) {
                     case 'yearly':
                         $node =& $doc->query($root . '/channel/' . $ns . ':updateFrequency');
                         $expires = $node->content * 31536000;
                         break;
                     case 'monthly':
                         $node =& $doc->query($root . '/channel/' . $ns . ':updateFrequency');
                         $expires = $node->content * 2592000;
                         break;
                     case 'weekly':
                         $node =& $doc->query($root . '/channel/' . $ns . ':updateFrequency');
                         $expires = $node->content * 604800;
                         break;
                     case 'daily':
                         $node =& $doc->query($root . '/channel/' . $ns . ':updateFrequency');
                         $expires = $node->content * 86400;
                         break;
                     case 'hourly':
                     default:
                         $node =& $doc->query($root . '/channel/' . $ns . ':updateFrequency');
                         $expires = $node->content * 3600;
                         break;
                 }
             } else {
                 // if all else fails, default to 1 hour
                 $expires = 3600;
             }
             // require an expiry time -- can't be none
         } elseif ($expires <= 0) {
             $expires = 3600;
         }
         $doc->_expires = time() + $expires;
         $ps->set($url, serialize($doc));
     }
     return $doc;
 }
Пример #6
0
<?php

loader_import('saf.Database.PropertySet');
$ps = new PropertySet('mailform', 'snippet');
echo $ps->get($parameters['code']);
Пример #7
0
loader_import('saf.Database.PropertySet');
$files = Dir::fetch($path, true);
$galleries = array();
if (!empty($parameters['path'])) {
    $prefix = $parameters['path'] . '/';
} else {
    $prefix = '';
}
if (intl_lang() == intl_default_lang()) {
    $ps1 = new PropertySet('sitegallery', 'album_title');
    $ps2 = new PropertySet('sitegallery', 'album_description');
    $ps3 = new PropertySet('sitegallery', 'album_date');
} else {
    $ps1 = new PropertySet('sitegallery', 'album_title_' . intl_lang());
    $ps2 = new PropertySet('sitegallery', 'album_description_' . intl_lang());
    $ps3 = new PropertySet('sitegallery', 'album_date');
}
foreach ($files as $k => $v) {
    if (!@is_dir($path . '/' . $v)) {
        continue;
    }
    $galleries[] = array('path' => $prefix . $v, 'name' => ucwords(preg_replace('/[^a-zA-Z\'-]+/', ' ', $v)), 'ts' => filemtime($path . '/' . $v), 'count' => sitegallery_count_images($path . '/' . $v), 'thumb' => sitegallery_get_thumbnail(sitegallery_first_image($path . '/' . $v)), 'desc' => '');
    $name = $ps1->get($prefix . $v);
    if (!empty($name)) {
        $galleries[count($galleries) - 1]['name'] = $name;
    }
    $desc = $ps2->get($prefix . $v);
    if (!empty($desc)) {
        $galleries[count($galleries) - 1]['desc'] = nl2br($desc);
    }
    $date = $ps3->get($prefix . $v);