示例#1
0
 /**
  *
  * @return type 
  */
 public static function newInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#2
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;
 }
示例#3
0
 public static function findThis()
 {
     if (!self::$instance) {
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#4
0
function getSiteInfo($key, $default_value)
{
    if (MULTISITE) {
        $_P = SiteInfo::newInstance();
        return $_P->get($key, $section);
    }
    return $default_value;
}
 public function admin_index()
 {
     if ($info = $_POST[SiteInfo::$formName]) {
         foreach ($info as $key => $value) {
             SiteInfo::findThis()->set($key, $value);
         }
     }
 }
 /**
  * Функція існує суто для сумісності із старими версіями
  * @deprecated since version 4.6
  * @param string $name
  * @param string $value
  * @return string|boolean
  */
 function siteInfoAdditionalManipulations($name)
 {
     if (FALSE !== strpos($name, '_path')) {
         $name = str_replace('_path', '', $name);
     }
     if (FALSE !== strpos($name, '_url')) {
         $name = str_replace('_url', '', $name);
     }
     $siteinfo = new SiteInfo();
     $value = $siteinfo->getSiteInfo($name);
     switch ($name) {
         case 'siteinfo_favicon':
         case 'siteinfo_logo':
             // із врахуванням активного шаблону
             if (is_array($value)) {
                 $settings = CI::$APP->cms_base->get_settings();
                 if (key_exists($settings['site_template'], $value)) {
                     $fileName = $value[$settings['site_template']];
                     if (SHOP_INSTALLED) {
                         $colorScheme = CI::$APP->load->module('template_manager')->getComponent('TColorScheme')->getColorSheme();
                         return "/templates/{$settings['site_template']}/css/{$colorScheme}/{$fileName}";
                     } else {
                         return "/templates/{$settings['site_template']}/images/{$fileName}";
                     }
                 } elseif (count($value) > 0) {
                     reset($value);
                     $key = key($value);
                     if (SHOP_INSTALLED) {
                         $colorScheme = CI::$APP->load->module('template_manager')->getComponent('TColorScheme')->getColorSheme();
                         $template = \template_manager\classes\TemplateManager::getInstance()->getCurentTemplate();
                         return "/templates/" . $template->name . "/css/{$colorScheme}/" . $value[$key];
                     } else {
                         return "/templates/{$settings['site_template']}/images/{$fileName}";
                     }
                 }
                 return '';
             } elseif (is_string($value)) {
                 return empty($value) ? '' : CI::$APP->siteinfo->imagesPath . $value;
             }
     }
     return false;
 }
示例#7
0
 public function actionView($code)
 {
     $code = zmf::filterInput($code, 't', 1);
     $info = SiteInfo::model()->find('code=:code', array(':code' => $code));
     if (!$info) {
         throw new CHttpException(404, '您所查看的页面不存在');
     }
     $allInfos = SiteInfo::model()->findAll(array('select' => 'code,title', 'condition' => 'status=' . Posts::STATUS_PASSED));
     //更新访问统计
     Posts::updateCount($info['id'], 'SiteInfo');
     $data = array('info' => $info, 'allInfos' => $allInfos, 'code' => $code);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->render('/site/siteinfo', $data);
 }
示例#8
0
 public function actionCreate($id = '')
 {
     if (!$this->uid) {
         $this->redirect(array('site/login'));
     }
     if ($id) {
         $model = $this->loadModel($id);
     } else {
         $model = new SiteInfo();
     }
     // Uncomment the following line if AJAX validation is needed
     // $this->performAjaxValidation($model);
     if (isset($_POST['SiteInfo'])) {
         $filter = Posts::handleContent($_POST['SiteInfo']['content']);
         $_POST['SiteInfo']['content'] = $filter['content'];
         if (!empty($filter['attachids'])) {
             $attkeys = array_filter(array_unique($filter['attachids']));
             if (!empty($attkeys)) {
                 $_POST['SiteInfo']['faceimg'] = $attkeys[0];
                 //默认将文章中的第一张图作为封面图
             }
         }
         $model->attributes = $_POST['SiteInfo'];
         if ($model->save()) {
             //将上传的图片置为通过
             Attachments::model()->updateAll(array('status' => Posts::STATUS_DELED), 'logid=:logid AND classify=:classify', array(':logid' => $model->id, ':classify' => 'siteinfo'));
             if (!empty($attkeys)) {
                 $attstr = join(',', $attkeys);
                 if ($attstr != '') {
                     Attachments::model()->updateAll(array('status' => Posts::STATUS_PASSED, 'logid' => $model->id), 'id IN(' . $attstr . ')');
                 }
             }
             $this->redirect(array('siteinfo/view', 'code' => $model->code));
         }
     }
     $this->render('/site/createSiteInfo', array('model' => $model));
 }
 function buildMenus($modules)
 {
     //get the persons available for the person issuing the request
     $persons = Site::getPersons();
     //the path to the modules directory
     $modulesPath = realpath(APPLICATION_PATH . '/modules');
     /**
      * Get the side wide menus first
      */
     $menus[] = SiteInfo::getMenu();
     foreach (array_values($modules) as $module) {
         $infoFile = "{$modulesPath}/{$module['name']}/Info.php";
         if ($module['status'] != 'active' || !is_file($infoFile)) {
             continue;
         }
         $menus[] = eval("return {$module['name']}" . '_Info::getMenu();');
         //self::getModulePages($persons, $moduleMenus, $menus);
     }
     Site::setResource('site_menu', serialize($menus));
 }
示例#10
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;
 }
示例#11
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;
 }
示例#12
0
 //$db_base = new db_class( $db_server, $db_name, $db_user, $db_pwd, $sys_charset );
 //print_r( $db_base );
 //包含 model,在这里检测包含处理用到的model
 //@include_once("../models/SiteInfo.php");
 include_once $sys_dir . "models/SiteInfo.php";
 /*if( 是直接访问 ){
 				
 			include_once("../models/SiteInfo.php");
 
 		}else{//通过index.php入口文件访问
 				
 			include_once("models/SiteInfo.php");
 
 		}
 		*/
 $db_base = new SiteInfo($db_server, $db_name, $db_user, $db_pwd, $sys_charset);
 //print_r( $db_base );
 //查询站点基本信息
 $siteinfo = $db_base->si_select('*', '');
 //print_r( $siteinfo );
 //遍历赋值 站点信息
 foreach ($siteinfo as $key => $value) {
     switch ($value["conf_name"]) {
         //系统名
         case "site_name":
             $siteinfo_new["site_name"] = $value["conf_value"];
             break;
             //关键字
         //关键字
         case "site_keywords":
             $siteinfo_new["site_keywords"] = $value["conf_value"];
示例#13
0
文件: _form.php 项目: ph7pal/momo
            <?php 
echo $form->labelEx($model, 'title');
?>
            <?php 
echo $form->textField($model, 'title', array('size' => 60, 'maxlength' => 255, 'class' => 'form-control'));
?>
            <?php 
echo $form->error($model, 'title');
?>
	</div>
        <div class="form-group">
            <?php 
echo $form->labelEx($model, 'code');
?>
            <?php 
echo $form->dropDownList($model, 'code', SiteInfo::exTypes('admin'), array('class' => 'form-control', 'empty' => '--请选择--'));
?>
            <?php 
echo $form->error($model, 'code');
?>
            <p class="help-block">每个主旨只能存在一篇文章</p>
	</div>
	<div class="form-group">
            <?php 
echo $form->labelEx($model, 'content');
?>
            <?php 
$this->renderPartial('/common/editor_um', array('model' => $model, 'content' => $model->content, 'uploadurl' => $uploadurl));
?>
            <?php 
echo $form->error($model, 'content');
示例#14
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>

示例#15
0
 public function siteInfo()
 {
     return SiteInfo::findThis();
 }
示例#16
0
 public function actionInfo()
 {
     $code = zmf::val('code', 1);
     $_title = SiteInfo::exTypes($code);
     if (!$_title) {
         throw new CHttpException(404, '您所查看的页面不存在');
     }
     $info = SiteInfo::model()->find('code=:code', array(':code' => $code));
     if (!$info) {
         throw new CHttpException(404, '您所查看的页面不存在');
     }
     $allInfos = SiteInfo::model()->findAll(array('select' => 'code,title', 'condition' => 'code!=:code AND status=' . Posts::STATUS_PASSED, 'params' => array(':code' => $code)));
     //更新访问统计
     Posts::updateCount($info['id'], 'SiteInfo');
     $data = array('info' => $info, 'code' => $code, 'allInfos' => $allInfos);
     $this->pageTitle = $info['title'] . ' - ' . zmf::config('sitename');
     $this->selectNav = 'about';
     $this->render('about', $data);
 }