예제 #1
0
 /**
  * Combines, minifies and caches internal js files
  *
  * @param $files an array of internal js filenames. should be in modules/jQuery - EX: 	array('soundmanager2.js', 'jquery.omniplayer.js')
  * @param $useCache the default is to use a cached version, but for testing changes you might want to set to false
  */
 public function packedScriptSrc($files, $useCache = true)
 {
     $hash = md5(join(',', $files));
     $fileName = $hash . '.min.js';
     $dir = $this->installPath . '/js/';
     $scriptDir = '/accelsite/js/';
     $metaKey = 'accel_js_cached_packed_' . $hash;
     $externalPath = $scriptDir . $fileName;
     if ($useCache) {
         if ($cachedSrc = SiteInfo::findThis()->getMeta($metaKey, 0)) {
             if (file_exists($dir . $fileName)) {
                 return $cachedSrc;
             }
         }
     }
     foreach ($files as $src) {
         $script .= file_get_contents($this->includePath . '/modules/jQuery/' . $src) . ";";
     }
     $packer = new JavaScriptPacker($script, 'Normal', true, false);
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     file_put_contents($dir . $fileName, $packer->pack() . "/*  cached:  " . date('r') . " */");
     SiteInfo::findThis()->setMeta($metaKey, $externalPath);
     return $externalPath;
 }
 public function admin_index()
 {
     if ($info = $_POST[SiteInfo::$formName]) {
         foreach ($info as $key => $value) {
             SiteInfo::findThis()->set($key, $value);
         }
     }
 }
예제 #3
0
 public static function findNearbyUsers($user)
 {
     $ret = array();
     if (!($geonamesUsername = SiteInfo::findThis()->get('geonames'))) {
         throw new Exception('You must get a username from geonames.org before using the method AP_UserUtils::findNearbyUsers');
     }
     if ($zip = $user->get('zip')) {
         $url = "http://api.geonames.org/findNearbyPostalCodesJSON?postalcode={$zip}&country=US&radius=30&username=" . $geonamesUsername;
         $zips = wp_cache_get($url, 'AP_UserUtils');
         if (!$zips) {
             $zips = ap_curl_json($url);
             $zips = ap_map_method($zips->postalCodes, 'postalCode');
             wp_cache_set($url, $zips, 'AP_UserUtils', self::$cache);
         }
         if ($zips) {
             if ($users = get_users(array('meta_query' => array(array('key' => 'zip', 'value' => $zips, 'compare' => 'IN'), array('key' => 'zip', 'compare' => 'EXISTS'))))) {
                 foreach ($users as $u) {
                     $ret[] = new AP_User($u);
                 }
             }
         }
     }
     return $ret;
 }
예제 #4
0
 public static function themeDropDown($name = 'themeID', $selected = NULL, $opts = null)
 {
     global $includePath, $installPath;
     if ($opts['mobile']) {
         $mobile = 'mobile/';
     }
     $ret .= "<select name='{$name}'>";
     $s = !$selected ? "selected='selected'" : "";
     if ($opts['blankFirst']) {
         $ret .= "<option value='' {$s}>None</option>";
     }
     // built in themes
     $ret .= "<optgroup label='Built-In Themes'>";
     $siteGroupID = SiteInfo::findThis()->siteGroupID();
     if ($siteGroupID > 0) {
         $v = $siteGroupID + 0.1;
         $stop = $v + 0.89;
         $increment = 0.1;
     } else {
         $v = 1;
         $stop = 100;
         $increment = 1;
     }
     while ($v <= $stop) {
         $themeName = NULL;
         $themeDir = $includePath . "/themes/" . $mobile . "temp" . $v . "/";
         if (file_exists($themeDir . "index.php")) {
             if (file_exists($themeDir . ".themename")) {
                 $handle = fopen($themeDir . ".themename", "r");
                 $themeName = fread($handle, filesize($themeDir . ".themename"));
                 fclose($handle);
             }
             if (!$themeName) {
                 $themeName = $v;
             }
             $s = $selected && (string) $selected == (string) $v ? "selected='selected'" : "";
             $ret .= "<option value=\"{$v}\" {$s}>{$v} - " . $themeName . "</option>\n";
         }
         $v += $increment;
     }
     // custom Themes
     $ret .= "</optgroup><optgroup label='Custom Themes'>";
     if (file_exists($installPath . '/themes/' . $mobile)) {
         $dh = opendir($installPath . '/themes/' . $mobile);
         while ($file = readdir($dh)) {
             $themeDir = $installPath . '/themes/' . $mobile . $file;
             if (preg_match('/^temp999(\\.\\d+)?$/', $file)) {
                 $themeID = str_replace('temp', '', $file);
                 $themeName = 'Custom ' . $themeID;
                 if (file_exists($themeDir . "/.themename")) {
                     $handle = fopen($themeDir . "/.themename", "r");
                     $themeName = fread($handle, filesize($themeDir . "/.themename"));
                     fclose($handle);
                 }
                 $s = $selected && (string) $selected == (string) $themeID ? "selected='selected'" : "";
                 $ret .= "<option value=\"{$themeID}\" {$s}>" . $themeName . "</option>\n";
             }
         }
     }
     $ret .= "</optgroup></select>";
     return $ret;
 }
예제 #5
0
<div class="wrap">
	<?php 
?>
<?php# screen_icon(); ?>
	<h2>Accelpress</h2>
	<div id="poststuff">
		<form method="post">
			<div class="widget postbox">
				<h3>Geonames</h3>
				<div class="inside">
					<p><em>To utilize the function AP_UserUtils::findNearbyUsers you'll need your own <a href="http://www.geonames.org/" target="_blank">geonames.org</a> username</em></p>
					<label for="geonames_username">Geonames Username</label> <input type="text" name="<?php 
echo SiteInfo::$formName;
?>
[geonames]" value="<?php 
echo SiteInfo::findThis()->get('geonames');
?>
" /> <input type="submit" class="button button-primary" value="Save" />

				</div>
			</div>
			<div class="widget postbox">
				<h3>Tests</h3>
				<div class="inside">
					<p><a class="run-tests button" href="#">Run Tests</a> <div id="test_results"></div></p>
				</div>
			</div>
		</form>
	</div>

예제 #6
0
 public function siteInfo()
 {
     return SiteInfo::findThis();
 }