示例#1
0
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     $is_admin = Request::is('admin*');
     $is_backend = Request::is('backend*');
     /* Set middleware(s) based on route URLs */
     if ($is_admin || $is_backend) {
         $this->middleware('auth');
         if ($is_backend) {
             // Backend specific middleware
             $this->middleware('auth.backend');
         }
         $this->middleware('auth.permissions');
         if (!Request::is('*users/change-password')) {
             // No validation for stale password if password is being changed
             $this->middleware('auth.pw_6_months');
         }
     }
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name')->all();
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
示例#2
0
 public function status()
 {
     if (Setting::value("{$this->target}_theme") == $this->id) {
         return 'Applied';
     } else {
         return 'Not Applied';
     }
 }
示例#3
0
 public function assets()
 {
     if ($this->user->can('edit_all_assets')) {
         $this->elfinder(NULL, trim(Setting::value('assets_folder', 'iu-assets'), '/'));
     } else {
         @mkdir(Setting::value('assets_folder', 'iu-assets') . '/' . $this->user->id, 0777, true);
         $this->elfinder(NULL, trim(Setting::value('assets_folder', 'iu-assets') . '/' . $this->user->id, '/'));
     }
 }
示例#4
0
 public function __construct()
 {
     parent::__construct();
     //$this->output->enable_profiler(TRUE);
     //check if config file is empty or it's not empty but script is not installed
     if ((is_db_conf_empty() || !is_installed()) && !defined('CS_EXTERNAL')) {
         redirect("setup/index");
     }
     //load database, datamapper and login manager
     $this->load->database();
     $this->load->library('datamapper');
     $this->load->library('translate');
     $this->load->library('loginmanager');
     //hack for datamapper prefix
     DataMapper::$config['prefix'] = $this->db->dbprefix;
     //set web site name in title
     $this->templatemanager->set_title(Setting::value('website_title', CS_PRODUCT_NAME));
     //test if should save uri
     $should = true;
     if ($this instanceof Process) {
         $uri = $path = trim($this->uri->uri_string());
         $file = new File();
         $file->path = $path;
         $mime = $file->mime_type();
         if ($mime !== 'text/html') {
             $should = false;
         }
     }
     //set current url for auth controller to know where to redirect
     if (!$this instanceof Auth && !$this instanceof JS && !$this->is_ajax_request() && $should) {
         $this->loginmanager->set_redirect(current_url());
     }
     //set time zone
     date_default_timezone_set(Setting::value('default_time_zone', 'Europe/Belgrade'));
     //set language
     $sess_lang = $this->session->userdata('lang');
     if (!empty($sess_lang)) {
         if (is_numeric($sess_lang)) {
             $lang = Language::factory()->get_by_id((int) $sess_lang)->name;
         } else {
             $lang = $sess_lang;
         }
     } else {
         $lang = Setting::value('default_language', 'English');
     }
     $this->translate->set_language($lang);
     //fetch user from the database if logged in
     if ($this->loginmanager->is_logged_in()) {
         $this->user = User::factory($this->loginmanager->user->id);
         $this->templatemanager->assign('user', $this->user);
     }
     $this->templatemanager->set_template_name($this->in_admin() ? "administration" : "");
     if ($this->in_admin() && isset($_GET['iu-popup'])) {
         $this->templatemanager->popup();
     }
 }
示例#5
0
 public function exportsql($zipped = false)
 {
     $this->load->dbutil();
     $sql = $this->dbutil->backup(array('format' => 'txt'));
     if (!empty($zipped)) {
         $this->load->library('zip');
         $this->zip->add_data(Setting::value("website_title", CS_PRODUCT_NAME) . '.sql', $sql);
         $this->zip->download(Setting::value("website_title", CS_PRODUCT_NAME) . '.sql.zip');
     } else {
         $this->load->helper('download');
         force_download(Setting::value("website_title", CS_PRODUCT_NAME) . '.sql', $sql);
     }
 }
示例#6
0
 /**
  * Initializer.
  *
  * @access   public
  * @return BaseController
  */
 public function __construct()
 {
     list($this->link_type, $this->link, $this->layout, $this->current_theme) = current_section();
     View::share('link_type', $this->link_type);
     View::share('current_theme', $this->current_theme);
     $website_settings = Setting::lists('value', 'name');
     View::share('website_settings', $website_settings);
     $locale = Setting::value('language');
     App::setLocale($locale);
     Lang::setLocale($locale);
     $this->user = current_user();
     View::share('current_user', $this->user);
     View::share('current_user_companies', current_user_companies());
 }
示例#7
0
 public function postContact()
 {
     $input = Input::all();
     $rules = array('email' => 'required|min:5|email', 'name' => 'required|alpha|min:5');
     $validator = Validator::make(Input::all(), $rules);
     if ($validator->fails()) {
         return Redirect::back()->withErrors($validator)->withInput();
     }
     try {
         Mail::send('public.' . $this->current_theme . '.email', $input, function ($message) use($input) {
             $message->from($input['email'], $input['name']);
             $message->to(Setting::value('email_username'), $input['name'])->subject($input['subject']);
         });
     } catch (Exception $e) {
         return Redirect::back()->withInput()->with('error_message', $e->getMessage());
     }
     return Redirect::back()->with('success_message', trans('success_messages.mail_sent'));
 }
示例#8
0
文件: backup.php 项目: jotavejv/CMS
 public function export()
 {
     $export_data = $this->input->post("export_data");
     $export_images = $this->input->post("export_images");
     $export_assets = $this->input->post("export_assets");
     if ($export_data) {
         $sql = $this->dbutil->backup(array('format' => 'txt'));
         $this->zip->add_data('database.sql', $sql);
     }
     if ($export_images) {
         $path = str_replace("\\", "/", FCPATH . "images\\");
         $this->zip->read_dir($path, false);
     }
     if ($export_assets) {
         $path = str_replace("\\", "/", FCPATH . "assets\\");
         $this->zip->read_dir($path, false);
     }
     $this->zip->download(cyr_url_title(Setting::value("website_title", CS_PRODUCT_NAME)) . ".zip");
 }
示例#9
0
文件: assets.php 项目: jotavejv/CMS
 public function quick_upload()
 {
     $assetdir = Setting::value('assets_folder', 'iu-assets') . '/' . $this->user->id;
     @mkdir($assetdir, 0777, true);
     $assetpath = realpath(trim($assetdir, '/')) . '/';
     $assetbase = rel2abs($assetdir, trim(base_url(), '/') . '/');
     // Optional: instance name (might be used to adjust the server folders for example)
     $CKEditor = $_GET['CKEditor'];
     // Required: Function number as indicated by CKEditor.
     $funcNum = $_GET['CKEditorFuncNum'];
     // Optional: To provide localized messages
     $langCode = $_GET['langCode'];
     // The returned url of the uploaded file
     $url = '';
     // Optional message to show to the user (file renamed, invalid file, not authenticated...)
     $message = '';
     // in CKEditor the file is sent as 'upload'
     if (isset($_FILES['upload'])) {
         $config = array();
         $config['upload_path'] = $assetdir;
         $config['allowed_types'] = '*';
         $this->load->library('upload', $config);
         if (!$this->upload->do_upload('upload')) {
             $message = $this->upload->display_errors();
         } else {
             $data = $this->upload->data();
             if (stripos(current_url(), 'instant-update.com') && empty($data['is_image'])) {
                 die(json_encode($result));
             }
             $url = $assetbase . '/' . $data['file_name'];
             //$result['url'] = base_url() . 'iu-assets/'.$this->user->id.'/'.$data['file_name'];
             $message = 'The file has been uploaded';
         }
     } else {
         $message = 'No file has been sent';
     }
     // ------------------------
     // Write output
     // ------------------------
     // We are in an iframe, so we must talk to the object in window.parent
     echo "<script type='text/javascript'> window.parent.CKEDITOR.tools.callFunction({$funcNum}, '{$url}', '{$message}')</script>";
 }
 /**
  * Execute the console command.
  *
  * @return void
  */
 public function fire()
 {
     DB::table('members_packages')->whereRaw("UNIX_TIMESTAMP(expiration) <= " . strtotime("NOW"))->update(array('status' => 0));
     echo "Membership packages has been updated.";
     // SENDS EMAIL TO THE MEMBERS WITH EXPIRED PACKAGES
     if (Setting::value('email_users_expire') == 'yes') {
         // FIND THE MEMBERS
         $packages = Memberpackage::where('status', '=', 0)->where('expiration', '=', date("Y-m-d 00:00:00"))->get();
         foreach ($packages as $package) {
             if ($package->member->email != '') {
                 $data = array('package' => $package->package->service->name, 'date' => date("F j,Y", strtotime($package->expiration)), 'name' => $package->member->first_name);
                 Mail::queue('emails.expired', $data, function ($message) use($package) {
                     $message->to($package->member->email, $package->member->first_name)->subject('You package has expired.');
                 });
             } else {
                 // SEND THROUGH SMS INSTEAD ( FUTURE FEATURE)
             }
         }
     }
 }
示例#11
0
 /**
  * Create backup of the current database
  * @param  string $current_time "Current time in string"
  */
 public function backupDB($current_time)
 {
     $this->dbConnections();
     $destination = backup_path() . "/backup/db/";
     // Clean the backup directory, before making any backup
     File::cleanDirectory(backup_path());
     File::makeDirectory(backup_path() . "/backup");
     File::makeDirectory($destination);
     $backup_filename = 'database_backup.sql';
     $path = \Setting::value('mysqldump_path', 'mysqldump');
     if (false) {
         if ($this->password == '') {
             //without password
             $command = $path . " -u " . $this->username . " " . $this->database . " > " . $destination . $backup_filename;
         } else {
             //with password
             $command = $path . " -u " . $this->username . " -p " . $this->password . " " . $this->database . " > " . $destination . $backup_filename;
         }
         system($command);
     } else {
         $this->backupTables($this->host, $this->username, $this->password, $this->database, $destination . $backup_filename);
     }
 }
示例#12
0
文件: helpers.php 项目: ratno/Doptor
/**
 * Get the information whether the current section is backend, admin or public
 * @return array
 */
function current_section()
{
    if (Schema::hasTable('themes') && Theme::all()->count() == 0) {
        // If for some reason, there are no themes in theme table, seed with the default data
        Artisan::call('db:seed', array('ThemesTableSeeder'));
    }
    if (Request::is('backend*') || Request::is('login/backend*')) {
        $link_type = 'backend';
        $link = 'backend/';
        $theme = Schema::hasTable('themes') ? Theme::find(Setting::value('backend_theme', 1))->directory : 'default';
        $layout = "backend.{$theme}._layouts._layout";
    } elseif (Request::is('admin*') || Request::is('login/admin*')) {
        $link_type = 'admin';
        $link = 'admin/';
        $theme = Schema::hasTable('themes') ? Theme::find(Setting::value('admin_theme', 1))->directory : 'default';
        $layout = "admin.{$theme}._layouts._layout";
    } else {
        $link_type = 'public';
        $link = '';
        $theme = Schema::hasTable('themes') ? Theme::find(Setting::value('public_theme', 1))->directory : 'default';
        $layout = "public.{$theme}._layouts._layout";
    }
    return array($link_type, $link, $layout, $theme);
}
示例#13
0
文件: auth.php 项目: jotavejv/CMS
 public function resetpass($id, $key)
 {
     $u = User::factory()->where('id', (int) $id)->where("key", $key)->get();
     if ($u->exists()) {
         $u->key = '';
         $u->active = 1;
         $u->salt = '';
         $p = random_string();
         $u->password = $p;
         $u->save();
         //set variables for template
         $vars = array('name' => $u->name, 'email' => $u->email, 'password' => $p, 'website_title' => Setting::value('website_title', CS_PRODUCT_NAME), 'site_url' => site_url());
         //get email template
         $template = file_get_contents(APPPATH . "templates/new_password.html");
         $template = __($template, null, 'email');
         $template .= "<br />\n<br />\n<br />\n" . __(file_get_contents(APPPATH . "templates/signature.html"), null, 'email');
         $template = parse_template($template, $vars);
         //send email
         $this->email->to("{$u->name} <{$u->email}>");
         $this->email->subject(__("%s password reset", Setting::value('website_title', CS_PRODUCT_NAME), 'email'));
         $this->email->message($template);
         $this->email->set_alt_message(strip_tags($template));
         $from = Setting::value("default_email", false);
         if (empty($from)) {
             $from = "noreply@" . get_domain_name(true);
         }
         $this->email->from($from);
         $sent = $this->email->send();
         if ($sent) {
             $this->templatemanager->notify_next(__("New password is set. Please check your e-mail."), "success", __("Success"));
         } else {
             $this->templatemanager->notify_next(__("E-mail could not be sent!"), "error", __("Error"));
         }
     } else {
         $this->templatemanager->notify_next(__("Invalid key or password already reset."), "error", __("Error"));
     }
     redirect("administration/auth/login");
 }
示例#14
0
文件: footer.php 项目: jotavejv/CMS
</div>

<?php 
if ($template->config['has_footer']) {
    ?>
    <!-- Footer line -->
<div id="footer">
<?php 
    $first = Setting::value('custom_footer_text', '');
    $second = Setting::value('custom_footer_text2', '');
    if (empty($first)) {
        $first = 'Content Management System provided by <a href="http://instant-update.com">Instant Update ' . get_app_version() . '</a>';
    }
    if (empty($second)) {
        $second = 'You can brand Instant Update as your own software (Settings > Branding).';
    }
    ?>
	<div class="left"><?php 
    echo $first;
    ?>
</div>
	<div class="right"><?php 
    echo $second;
    ?>
</div>
</div>
<?php 
}
?>

<?php 
示例#15
0
function remove_image(id)
{
	$.get(IU_SITE_URL+'/administration/repeatables/ajax_removeimage/'+id, function () {
		$('#item-image').fadeOut();
	}, 'json');
}

$(document).ready(function() {
	$( ".datepicker" ).datepicker({
		autoSize: true,
		appendText: '(<?php 
echo Setting::value('datepicker_format', 'dd/mm/yy');
?>
)',
		dateFormat: '<?php 
echo Setting::value('datepicker_format', 'dd/mm/yy');
?>
'
	});
});

<?php 
if ($template->config['has_header']) {
    ?>
var myheight = screen.height;
<?php 
} else {
    ?>
var myheight = Math.floor(screen.height * 0.6);
<?php 
}
示例#16
0
 public function uri()
 {
     //get request uri
     $uri = $path = trim($this->uri->uri_string(), '/');
     if ($path == '.htaccess') {
         show_404($path);
     }
     //if uri is empty assign index.html or index.php (if index.html doesn't exist)
     if (empty($uri)) {
         $uri = $path = "index.htm";
         if (!is_file($path)) {
             $path = "index-original.htm";
         }
         if (!is_file($path)) {
             $uri = $path = "index.html";
         }
         if (!is_file($path)) {
             $path = "index-original.html";
         }
         if (!is_file($path)) {
             $uri = "index.php";
             $path = "index-original.php";
         }
     } elseif (is_dir($path)) {
         $p = rtrim($path, '/') . '/index.htm';
         if (!is_file($p)) {
             $p = rtrim($path, '/') . '/index.html';
         }
         if (!is_file($p)) {
             $p = rtrim($path, '/') . '/index.php';
         }
         $uri = $path = $p;
     }
     //fix for bad linking
     /*if (current_url() == site_url())
     		{
     			redirect(site_url($uri));
     			die;
     		}//*/
     //get page
     $this->page = $page = Page::factory()->get_by_uri($uri);
     //get file obj from db
     if (!$page->exists()) {
         $file = File::factory()->get_by_path($path);
     } else {
         $file = $page->file->get();
     }
     //if file doesn't exists in database, check if it needs to be saved in the
     // db and save it (if needed)
     if (!$file->exists()) {
         $file->path = $path;
         //if file doesn't exists on disk either, show 404
         if (!is_file($file->path)) {
             show_404($path);
         }
         $file->checksum = md5_file($file->path);
         //if user is logged in, add him as last editor
         if (!empty($this->user)) {
             $file->editor_id = $this->user->id;
         }
         //if html file, save it to the database
         if ($file->mime_type() == 'text/html') {
             $file->save();
         }
     }
     //if file exists in the database, check it and push it :)
     if ($file->mime_type() !== 'text/html') {
         $file->push();
     }
     $newpage = false;
     //if page doesn't exist
     if (!$page->exists()) {
         if (!$file->exists()) {
             //no page and no file!?
             show_404($uri);
         } else {
             $page->title = $file->get_title();
             $page->keywords = $file->get_meta('keywords');
             $page->description = $file->get_meta('description');
             $save2 = array($file);
             if (!empty($this->user)) {
                 $save2[] = $this->user;
             }
             $page->uri = $uri;
             $page->save($save2);
         }
         //new page!
         $newpage = true;
     } else {
         //check for file
         $f = $page->file->get();
         if ($f->exists()) {
             //if there is a file, assign it;
             $file = $f;
         } else {
             //assign default file
             if (is_file($page->uri)) {
                 $file = new File();
                 $file->path = $page->uri;
                 $file->checksum = md5_file($file->path);
                 if (!empty($this->user)) {
                     $file->editor_id = $this->user->id;
                 }
                 $file->save();
             } else {
                 $file = File::factory()->order_by('default DESC')->limit(1)->get();
             }
             $page->save(array($file));
         }
     }
     //write stats if not logged in
     if (empty($this->user)) {
         //read cookie and hit variables (ip address, user agent, etc)
         $cookie = $this->input->cookie('__iuvfc');
         $ip_address = $this->input->ip_address();
         $user_agent = $this->input->user_agent();
         $this->load->library('user_agent');
         //create and fill hit
         $hit = new Hit();
         $hit->os = BrowserOS::get_os($user_agent);
         $hit->browser = BrowserOS::get_browser_no_version($user_agent);
         $hit->ip_address = $ip_address;
         $hit->returning = !empty($cookie);
         //get page referer
         $referer = $this->agent->referrer();
         if (!empty($referer)) {
             //if referer is not coming from our site, write it to hit
             $domain = str_replace('www.', '', parse_url($referer, PHP_URL_HOST));
             $this_domain = str_replace('www.', '', parse_url(site_url(), PHP_URL_HOST));
             if ($domain != $this_domain) {
                 $hit->referer = $referer;
                 $hit->referer_domain = $domain;
             }
         }
         //set cookie for returning visitors
         $cookie = array('name' => '__iuvfc', 'value' => time(), 'expire' => 3600 * 24 * 30 * 12);
         $this->input->set_cookie($cookie);
         //define geoip database path
         $geoip_db_filename = './iu-resources/geoip/GeoIP.dat';
         //if geoip database exists
         if (is_file($geoip_db_filename)) {
             //we have a geoip db, store country
             $this->load->helper('geoip');
             $gi = @geoip_open($geoip_db_filename, GEOIP_STANDARD);
             $country_name = @geoip_country_name_by_addr($gi, $ip_address);
             if (empty($country_name)) {
                 $country_name = null;
             }
             $hit->country = $country_name;
         }
         if (!empty($hit->os) && !empty($hit->browser)) {
             $hit->save(array($page));
         }
     }
     //cache if logged out, not an ajax request and
     $this->load->library('cache');
     $this->cache->set_uri($page->uri);
     $cache_time = $page->cache_duration();
     if (empty($this->user) && !$this->is_ajax_request() && $file->mime_type() == 'text/html') {
         if ($cache_time > 0 && $this->cache->cache_exists($cache_time * 60)) {
             if (Setting::value('use_tidy', 'yes') == 'yes') {
                 die(html_tidy($this->cache->load_cache(false)));
             } else {
                 die($this->cache->load_cache(false));
             }
         }
     }
     /***** START PROCESSING HTML *****/
     if (!empty($page->title)) {
         $title = $page->title;
         $append_sitename = Setting::value('append_sitename_titles', 'yes') == 'yes';
         if ($append_sitename) {
             $title .= ' | ' . Setting::value('website_title');
         }
         $page->set_title($title);
     }
     //add meta tags
     if (!empty($page->keywords)) {
         $page->set_meta('keywords', $page->keywords);
     }
     if (!empty($page->description)) {
         $page->set_meta('description', $page->description);
     }
     //$page->set_meta('generator', 'Instant Update '.get_app_version());
     $page->set_encoding('utf-8');
     //$page->set_base_href();
     //embed jquery
     $page->embed('iu-resources/js/jquery.js');
     //embed jquery ui
     //$page->embed('iu-resources/js/jquery-ui.min.js');
     //$page->embed('iu-resources/css/bootstrap/bootstrap.css');
     $page->embed('iu-resources/min/?g=base-css', 'css');
     //dynamically define js variables
     $page->embed('iu-dynamic-js/init.js', null, false);
     //lightbox
     //$page->embed('http://fonts.googleapis.com/css?family=Mako', 'css');
     //$page->embed('iu-resources/lightbox/css/jackbox.css');
     //$page->embed_IE('iu-resources/lightbox/css/jackbox-ie8.css', 'lt', 9);
     $page->embed_IE('http://html5shiv.googlecode.com/svn/trunk/html5.js', 'lt', 9);
     /*$page->embed_IE('iu-resources/lightbox/css/jackbox-ie9.css', 'gt', 8);
     		$page->embed('iu-resources/lightbox/js/libs/Jacked.js');
     		$page->embed('iu-resources/lightbox/js/jackbox.js');*/
     $page->embed('iu-resources/min/?g=base-js', 'js');
     //load functions
     //$page->embed('iu-resources/js/phpjs.js');
     //$page->embed('iu-resources/js/functions.js');
     //embed webfont
     //$page->embed('http://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js');
     //$page->embed('iu-resources/js/webfont.js');
     //embed jQ pagination
     //$page->embed('iu-resources/js/jquery.simplePagination.js');
     //$page->embed('iu-resources/css/simplePagination.css');
     //$page->embed('iu-resources/js/jquery.masonry.min.js');
     //$page->embed('iu-resources/js/jquery.scrollTo.min.js');
     //buttons
     //$page->embed('iu-resources/css/buttons.css');
     if (!empty($this->user)) {
         $page->embed('iu-application/views/administration/ckeditor/ckeditor.js');
         $page->embed('iu-resources/min/?g=user-js', 'js');
         //embed hallo (admin)
         //$page->embed('iu-resources/js/rangy/rangy-core.js');
         //$page->embed('iu-resources/js/hallo.js');
         //$page->embed('iu-resources/css/hallo.css');
         //$page->embed('iu-resources/css/image.css');
         //$page->embed('iu-resources/fontawesome/css/font-awesome.css');
         //$page->embed_IE('iu-resources/fontawesome/css/font-awesome-ie7.css', 'lt', 7);
         //splight
         //$page->embed('iu-resources/js/jquery.spotlight.pack.js');
         //embed jqconfigurator (admin only)
         //$page->embed('iu-resources/js/jqconfigurator.js');
         //msgbox
         //$page->embed('iu-resources/msgbox/jquery.msgbox.min.js');
         //$page->embed('iu-resources/msgbox/jquery.msgbox.css');
         //embed jgrowl (admin)
         //$page->embed('iu-resources/css/jquery.jgrowl.css');
         //$page->embed('iu-resources/js/jquery.jgrowl.min.js');
         //menu
         //$page->embed('iu-resources/css/pathmenu.min.css');
         //$page->embed('iu-resources/js/pathmenu.3.2.min.js');
         //embed header
         //$page->embed('iu-resources/css/iu-header.css');
     }
     //this loads at the end
     //$page->embed('iu-resources/css/style.css');
     //...if user is logged in
     //	if (!empty($this->user))
     //	$page->embed('iu-resources/js/instant.js', null, true);
     //$page->embed('iu-resources/js/domready.js', null, true);
     //process contents
     $blocks = $page->dom()->find('div[id],ol[id],ul[id],article[id],section[id],aside[id],content[id],menu[id],nav[id]');
     //load contentparser abstract class
     require_once "./iu-application/libraries/contentprocessor.php";
     foreach ($blocks as $block) {
         //skip div if it has class iu-skip
         if (stripos((string) $block->class, 'iu-skip') !== false) {
             continue;
         }
         //skip div if it contains other divs with id (except if it's marked with iu-content)
         $subdivs = $block->find('div[id],ol[id],ul[id],article[id],section[id],aside[id],content[id],menu[id],nav[id]');
         if ($subdivs != null && stripos((string) $block->class, 'iu-content') === false) {
             continue;
         }
         //*/
         $div_id = $block->id;
         $c = Content::factory()->where('div', $div_id)->group_start()->where_related_page('id', $page->id)->or_where('is_global', TRUE)->group_end()->limit(1)->get();
         //get classes
         if (empty($block->class)) {
             $classes = array();
         } else {
             $classes = explode(' ', $block->class);
         }
         //assume html type
         $ctype_class = 'Html';
         //if content exists in the database, get it's content type
         /*if ($c->exists())
         			{
         				$ctype_class = $c->contenttype->get()->classname;
         			}
         			//otherwise, guess content type from assigned class
         			else
         			{
         				//loop over all classes and process those starting with iu-content-
         				foreach ($classes as $classname)
         				{
         					$classname = strtolower($classname);
         					if (strpos($classname, 'iu-content-') === 0)
         					{
         						$parts = explode('-', $classname);
         						if (count($parts) != 3)
         							continue;
         
         						$ctype_class = ucfirst($parts[2]);
         						break;
         					}
         				}
         
         			}//*/
         //load class if it isn't loaded
         if (!class_exists($ctype_class)) {
             require_once "./iu-application/libraries/contents/{$ctype_class}.php";
         }
         //process block
         $instance =& get_instance();
         $ctype = new $ctype_class($instance);
         $block = call_user_func(array($ctype, 'process'), $block, $c, $page);
         //process via plugin
         //$block = PluginManager::do_actions('process.content', array($block, $c, $page));
         if (is_array($block)) {
             $block = $block[0];
         }
         //add DB ID if exists in DB
         if ($c->exists()) {
             $block->setAttribute('data-id', $c->id);
         }
         //get classes
         if (empty($block->class)) {
             $classes = array();
         } else {
             $classes = explode(' ', $block->class);
         }
         //if no classes starting with "iu-" - assume editable (StaticHTML)
         if (strpos($block->class, 'iu-content-') === false) {
             $classes[] = "iu-content-html";
         }
         //mark as global
         if (!empty($c->is_global)) {
             $classes[] = "iu-global";
         }
         $block->class = implode(' ', $classes);
         //if can edit
         if (!empty($this->user) && $this->user->can_edit_content($c)) {
             $block->setAttribute('data-canedit', 'true');
         }
     }
     //change title/desc for single item
     /*$single = $this->input->get('read');
     		if (!empty($single))
     		{
     			$parts = explode('-', $single);
     			$id = (int)$parts[0];
     			$item = RepeatableItem::factory($id);
     			$append_sitename = Setting::value('append_sitename_titles', 'yes') == 'yes';
     			$title = strip_tags($item->title);
     
     			if ($append_sitename)
     				$title .= ' | ' . Setting::value('website_title');
     
     			$page->set_title($title);
     			$page->set_meta('description', character_limiter(strip_tags($item->text), 150));
     			$page->set_meta('keywords', strip_tags($item->title));
     		}//*/
     $page->body()->setAttribute('data-uri', $page->uri);
     $page->body()->setAttribute('data-id', $page->id);
     $page->body()->setAttribute('data-template', $page->file->path);
     if ($newpage) {
         $page->body()->setAttribute('data-newpage', 'true');
     }
     //var_dump($page->body()->{'data-uri'}); die;
     if (!empty($this->user) && $this->user->can_edit_page($page)) {
         $page->body()->setAttribute('data-canedit', 'true');
     }
     /*$submenu = new AdminMenuItem('Page Summary', 'iu-icon-info', null, true);
     			$item2 = new AdminMenuItem(
     								"URI: <strong>/". $page->uri."</strong><br />\n"
     								. "Title: <strong>". character_limiter( $page->get_title(), 30 )."</strong><br />\n"
     								. "Last modified: <strong>".(empty($page->updated)? 'Never' : date('d.m.Y. \@ H:i', $page->updated))."</strong><br />\n"
     								. "File: <strong>/".$file->path."</strong><br />\n"
     								, null, null, false);
     			$item21 = new AdminMenuItem("Edit Page Settings", 'iu-icon-page-gear', site_url('administraton/pages/edit/'.$page->uri), false);
     
     		$submenu->add_item($item2);
     		$submenu->add_item($item21);
     
     		$item = new AdminMenuItem('Edit Source File', 'iu-icon-file-edit', site_url('administration/files/edit/'.$file->path), true);
     
     
     		$page->menu()->add_item($submenu);
     		$page->menu()->add_item($item);
     		$page->menu()->add_item(new AdminMenuItem('Administration Area', 'iu-icon-home', site_url('administration/dashboard'), true, 'iu-logout-icon'));
     		$page->menu()->add_item(new AdminMenuItem('Log Out', 'iu-icon-logout', site_url('administration/auth/logout'), true, 'iu-logout-icon'));
     //*/
     if (!empty($this->user)) {
         $page->body()->innertext = '<div id="fb-root" class="iu-skip"></div><div id="iu-menu" class="iu-skip"></div><div id="iu-jgrowl" class="iu-skip"></div>' . $page->body()->innertext;
     }
     //analytics
     $analytics_id = Setting::value('google_analytics_id', false);
     if (!empty($analytics_id)) {
         $page->body()->innertext .= "<script type=\"text/javascript\">\n\n  var _gaq = _gaq || [];\n  _gaq.push(['_setAccount', '{$analytics_id}']);\n  _gaq.push(['_trackPageview']);\n\n  (function() {\n    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\n    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\n    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n  })();\n\n</script>";
     }
     $page->prefix_relative_links();
     //$page = PluginManager::do_actions('process.page', $page);
     $html_code = $page->dom()->save();
     if (empty($this->user) && !$this->is_ajax_request() && $file->mime_type() == 'text/html' && $cache_time > 0) {
         $this->cache->save_cache($html_code);
     }
     if (Setting::value('use_tidy', 'yes') == 'yes') {
         $this->load->library('format');
         die($this->format->HTML($html_code));
         //die(html_tidy($html_code));
     } else {
         die($html_code);
     }
 }
示例#17
0
文件: helpers.php 项目: doptor/doptor
/**
 * Does the current public theme has theme settings or not
 * @return boolean
 */
function has_theme_settings()
{
    $public_theme_id = Setting::value('public_theme');
    $public_theme = Theme::findOrFail($public_theme_id);
    return $public_theme->has_settings;
}
示例#18
0
			            <th>Created</th>
						<th>Actions</th>
		            </tr>
	            </thead>
	            <tbody>
		            <?php 
$revs = FileRevision::factory()->where_related_file('id', $file->id)->order_by('created DESC')->get();
foreach ($revs as $rev) {
    ?>
		            <tr class="gradeA">
		            	<td><?php 
    echo $rev->id;
    ?>
</td>
						<td><?php 
    echo empty($rev->created) ? "&mdash;" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $rev->created) . '">' . relative_time($rev->created) . '</span> ' . __('by %s', $rev->user->get()->name);
    ?>
</td>
						<td class="actBtns2">
							<a title="Compare with this version" href="<?php 
    echo site_url('administration/templates/diff/' . $file->id . '/' . $rev->id);
    ?>
" class="iu-btn">Compare</a>
                           <a title="Revert to this version" style="margin-left:2px !important" href="javascript:;" onclick="revert(<?php 
    echo $file->id;
    ?>
, <?php 
    echo $rev->id;
    ?>
);" class="iu-btn danger">Revert</a>
示例#19
0
</strong></li>
                        </ul>
                        <ul class="rightList">
                        <?php 
    $updates = $user->contentrevision->order_by_related_content('updated', 'DESC')->get();
    $cnt = $updates->result_count();
    ?>
                            <li><strong><?php 
    echo $cnt;
    ?>
 content update<?php 
    echo $cnt != 1 ? 's' : '';
    ?>
</strong></li>
                            <li>Last update: <?php 
    echo $cnt > 0 ? date(Setting::value('datetime_format', 'F j, Y @ H:i'), $updates->all[0]->content->get()->updated) : 'never';
    ?>
</li>
                        </ul>
                        <div class="clear"></div>
                    </div>
                    <div class="cLine"></div>
                    <?php 
}
?>



                </div> -->

            <!-- Accordion --><!-- Widget with ajax loader --><!-- Tabs -->
示例#20
0
if ($_IU->user->can('edit_templates')) {
    ?>
        var base = iu_root_url(IU_BASE_URL);
<?php 
} elseif ($_IU->user->can('edit_all_assets')) {
    ?>
        var base = iu_root_url(IU_BASE_URL + "<?php 
    echo Setting::value('assets_folder', 'iu-assets');
    ?>
");
<?php 
} else {
    @mkdir('../../../../../' . Setting::value('assets_folder', 'iu-assets') . '/' . $_IU->user->id, 0777, true);
    ?>
		var base = iu_root_url(IU_BASE_URL + "<?php 
    echo Setting::value('assets_folder', 'iu-assets');
    ?>
/<?php 
    echo $_IU->user->id;
    ?>
");
<?php 
}
?>
        var readonly = false;
        var fullpath = true;
		
		//alert(base);

        $(document).ready(function () {
示例#21
0
 public function postResetPassword()
 {
     $input = Input::all();
     try {
         $user = Sentry::findUserById($input['id']);
         if ($input['username'] != $user->username || $input['security_answer'] != $user->security_answer) {
             return Redirect::back()->withInput()->with('error_message', 'Either the username or security answer is incorrect');
         }
         if ($user->checkResetPasswordCode($input['token'])) {
             if ($user->attemptResetPassword($input['token'], $input['password'])) {
                 $data = array('user_id' => $user->id, 'created_at' => strtotime($user->created_at) * 1000);
                 Mail::queue('backend.' . $this->current_theme . '.reset_password_confirm_email', $data, function ($message) use($input, $user) {
                     $message->from(get_setting('email_username'), Setting::value('website_name'))->to($user->email, "{$user->first_name} {$user->last_name}")->subject('Password Reset Confirmation');
                 });
                 $user->last_pw_changed = date('Y-m-d h:i:s');
                 $user->save();
                 return Redirect::to("login/{$input['target']}")->with('success_message', 'Password reset is successful. Now you can log in with your new password');
             } else {
                 return Redirect::back()->with('error_message', 'Password reset failed');
             }
         } else {
             return Redirect::back()->withErrors(array('invalid_reset_code' => 'The provided password reset code is invalid'));
         }
     } catch (Cartalyst\Sentry\Users\UserNotFoundException $e) {
         return Redirect::back()->with('error_message', 'The specified user doesn\'t exist');
     }
 }
示例#22
0
文件: user.php 项目: jotavejv/CMS
 public function assets_path()
 {
     $assets_folder = Setting::value('assets_folder', false);
     if (empty($assets_folder)) {
         return false;
     }
     if ($this->can('edit_all_assets')) {
         $folder = $assets_folder;
     }
     if ($this->can('edit_assets')) {
         $folder = $assets_folder . '/' . $this->id;
     } else {
         return false;
     }
     if (!is_dir($folder)) {
         @mkdir($folder, 0777, true);
     }
     return is_dir($folder) ? $folder . '/' : false;
 }
示例#23
0
 public function process_template($newdomitem, $i, $page)
 {
     $single = $this->_IU->input->get('read');
     $logged_in = !empty($this->_IU->user);
     //set title, and link it if it's <a> tag
     $titlefield = $newdomitem->find('.iu-item-title');
     foreach ($titlefield as $field) {
         $field->innertext = $i->title;
         if (strtolower(trim($field->tag)) == 'a') {
             if (!empty($single)) {
                 $field->href = 'javascript:;';
             } else {
                 $format = empty($field->{'data-format'}) ? '%page_url%?%read_slug%=%seo_title%' : (string) $field->{'data-format'};
                 $seo_title = $i->id . '-' . cyr_url_title($i->title);
                 $url = str_replace('%page_url%', site_url($page->uri), $format);
                 $url = str_replace('%read_slug%', $this->read_slug, $url);
                 $url = str_replace('%seo_title%', $seo_title, $url);
                 $url = str_replace('%base_url%', base_url(), $url);
                 $url = str_replace('%site_url%', site_url(), $url);
                 $field->href = $url;
             }
         }
     }
     //set link for <a> element; usable for "read more" links
     $itemlnks = $newdomitem->find('.iu-item-url');
     foreach ($itemlnks as $lnk) {
         if (strtolower(trim($lnk->tag)) != 'a') {
             continue;
         }
         $format = empty($lnk->{'data-format'}) ? '%page_url%?%read_slug%=%seo_title%' : (string) $lnk->{'data-format'};
         $seo_title = $i->id . '-' . cyr_url_title($i->title);
         $url = str_replace('%page_url%', site_url($page->uri), $format);
         $url = str_replace('%read_slug%', $this->read_slug, $url);
         $url = str_replace('%seo_title%', $seo_title, $url);
         $url = str_replace('%base_url%', base_url(), $url);
         $url = str_replace('%site_url%', site_url(), $url);
         $lnk->href = $url;
     }
     //fill out author name
     $authorfield = $newdomitem->find('.iu-item-author');
     foreach ($authorfield as $field) {
         $field->innertext = $i->user->get()->name;
     }
     //fill out text field
     $textfield = $newdomitem->find('.iu-item-text');
     foreach ($textfield as $field) {
         $limit = empty($field->{'data-limit'}) ? 0 : (int) $field->{'data-limit'};
         //never show excerpt to a logged in user
         if ($logged_in) {
             $shortened = false;
         } else {
             $shortened = $single == false && $limit > 0;
         }
         if ($shortened) {
             $format = empty($field->{'data-format'}) ? '%page_url%?%read_slug%=%seo_title%' : (string) $field->{'data-format'};
             $readmore = empty($field->{'data-readmore'}) ? 'read more &raquo;' : (string) $field->{'data-readmore'};
             $seo_title = $i->id . '-' . cyr_url_title($i->title);
             $url = str_replace('%page_url%', site_url($page->uri), $format);
             $url = str_replace('%read_slug%', $this->read_slug, $url);
             $url = str_replace('%seo_title%', $seo_title, $url);
             $url = str_replace('%base_url%', base_url(), $url);
             $url = str_replace('%site_url%', site_url(), $url);
             $field->href = $url;
             $field->innertext = character_limiter($i->text, $limit);
             $field->innertext .= ' <a href="' . $url . '" class="iu-read-more">' . $readmore . '</a>';
         } else {
             $field->innertext = $i->text;
         }
     }
     //set images (and resize them)
     $images = $newdomitem->find('.iu-item-image');
     foreach ($images as $img) {
         if (strtolower(trim($img->tag)) != 'img') {
             continue;
         }
         $width = preg_replace('/[^0-9]+/', '', $img->width);
         if (empty($width)) {
             $width = 300;
         }
         $height = preg_replace('/[^0-9]+/', '', $img->height);
         if (empty($height)) {
             $height = 0;
         }
         $im = new Image($i->image);
         $img->src = $im->thumbnail($width, $height)->url;
         $img->setAttribute('data-fullimg', $im->uri);
         $img->alt = $img->title = $i->title;
         if (!empty($single)) {
             $img->onclick = 'return iu_popup_image(this, \'' . $i->title . '\');';
         }
     }
     //set image links for <a> elements
     $imagelnks = $newdomitem->find('.iu-item-image-url');
     foreach ($imagelnks as $lnk) {
         if (strtolower(trim($lnk->tag)) != 'a') {
             continue;
         }
         if (!empty($i->image)) {
             $im = new Image($i->image);
             $lnk->href = $im->url;
         }
     }
     //set date
     $datefield = $newdomitem->find('.iu-item-date');
     foreach ($datefield as $field) {
         $format = empty($field->{'data-format'}) ? Setting::value('datetime_format', 'F j, Y @ H:i') : $field->{'data-format'};
         $field->innertext = date($format, $i->timestamp);
     }
     //add id
     $idfield = $newdomitem->find('.iu-item-id', 0);
     if (!empty($idfield)) {
         $idfield->value = $i->id;
     } else {
         $newdomitem->innertext .= '<input type="hidden" class="iu-item-id" value="' . $i->id . '" />';
     }
     //add comments on single pages
     $comments = Setting::value('comments_enabled', 'no');
     if ($single !== false && $comments != 'no') {
         $comments_engine = Setting::value('comments_engine_id', 'no');
         if ($comments == 'Disqus') {
             $html = '<div id="disqus_thread"></div>';
         } else {
             $html = '<div style="text-align: center;" id="facebook_thread" class="fb-comments" data-href="' . site_url($page->uri) . '?read=' . $i->id . '-' . cyr_url_title($i->title) . '" data-num-posts="2"></div>';
         }
         $newdomitem->innertext .= $html;
     }
     //add new item to placeholder
     return $newdomitem->outertext . "\n\n";
 }
示例#24
0
</a></span></td>
			<td><span<?php 
    echo strlen($page->uri) > $l ? ' class="tipW" title="' . $page->uri . '"' : "";
    ?>
><a href="<?php 
    echo site_url($page->uri);
    ?>
" class="highlightLink"><?php 
    echo ellipsize($page->uri, $l, 0.5);
    ?>
</a></span><span style="display: none;"><?php 
    echo $page->uri;
    ?>
</span></td>
            <td class="center"><?php 
    echo empty($rep->updated) ? "&mdash;" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $rep->updated) . '">' . relative_time($rep->updated) . '</span> ' . __('by %s', User::factory($rep->editor_id)->name);
    ?>
</td>
			<td class="center"><?php 
    $fnd = $rep->repeatableitem->get()->result_count();
    echo $fnd;
    ?>
 item<?php 
    echo $fnd != 1 ? 's' : '';
    ?>
 found</td>
            <td class="actBtns">
				<a title="Edit" href="<?php 
    echo site_url('administration/contents/edit/' . $rep->id . '/' . $rep->div);
    ?>
"  class="tipN"><img src="<?php 
示例#25
0
" <?php 
    echo isset($page) && !$page->custom_caching ? 'disabled="disabled"' : '';
    ?>
 /> <span class="formNote">Duration is set in minutes. There are 60 minutes in one hour, 1440 in one day and 10080 minutes in one week.</span>
                       	</div>
                       	<div class="clear"></div>
                   	</div>
                   	<?php 
    if (isset($page)) {
        ?>
                   	<?php 
        $system->load->library('cache');
        $system->cache->set_uri($page->uri);
        if ($system->cache->cache_exists($page->cache_duration() * 60)) {
            $cached = true;
            $cache_date = date(Setting::value('datetime_format', 'F j, Y @ H:i'), filemtime($system->cache->get_cache_file()));
        } else {
            $cached = false;
            $cache_date = 'cache doesn\'t exist';
        }
        ?>
                   	<p id="cache_status">Cache status: <?php 
        if ($cached) {
            ?>
saved on <?php 
            echo $cache_date;
            ?>
 &bull; <a href="javascript:;" onclick="ajax_remove_cache(<?php 
            echo $page->id;
            ?>
);">Remove</a> <?php 
示例#26
0
    ?>
</a></td>
			<td><?php 
    echo $user->email;
    ?>
</td>
			<td class="center"><?php 
    echo $user->userrole->name;
    ?>
</td>
            <td class="center"><?php 
    echo empty($user->created) ? "&mdash;" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $user->created) . '">' . relative_time($user->created) . '</span>';
    ?>
</td>
            <td class="center"><?php 
    echo empty($user->last_updated_content()->updated) ? "&mdash;" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $user->last_updated_content()->updated) . '">' . relative_time($user->last_updated_content()->updated) . '</span> ';
    ?>
</td>
			<td class="actBtns">
				<a title="Edit" href="<?php 
    echo site_url('administration/users/edit/' . $user->id);
    ?>
" class="tipN"><img src="<?php 
    echo $template->base_url();
    ?>
images/icons/edit.png" alt=""></a>
				<a title="Remove" href="javascript:;" onclick="remove_user(<?php 
    echo $user->id;
    ?>
, '<?php 
    echo $user->name;
示例#27
0
 /**
  * Remove the specified theme from storage.
  *
  * @param  int  $id
  * @return Response
  */
 public function destroy($id = null)
 {
     // If multiple ids are specified
     if ($id == 'multiple') {
         $selected_ids = trim(Input::get('selected_ids'));
         if ($selected_ids == '') {
             return Redirect::back()->with('error_message', trans('error_messages.nothing_selected_delete'));
         }
         $selected_ids = explode(' ', $selected_ids);
     } else {
         $selected_ids = array($id);
     }
     foreach ($selected_ids as $id) {
         $theme = Theme::findOrFail($id);
         if (\Setting::value("{$theme->target}_theme") == $theme->id) {
             return Redirect::back()->with('error_message', "The theme {$theme->name} can not be deleted because it is currently being used as {$theme->target} theme.");
         }
         File::delete($theme->screenshot);
         File::deleteDirectory(app_path() . "/../resources/views/{$theme->target}/{$theme->directory}/", false);
         File::deleteDirectory(public_path() . "/assets/{$theme->target}/{$theme->directory}/", false);
         $theme->delete();
     }
     $wasOrWere = count($selected_ids) > 1 ? 's were' : ' was';
     $message = 'The theme' . $wasOrWere . ' deleted.';
     return Redirect::to("backend/theme-manager")->with('success_message', $message);
 }
示例#28
0
    <script type="text/javascript" src="{!! URL::to('assets/shared/countdown/jquery.plugin.js')!!}"></script>
    <script type="text/javascript" src="{!! URL::to('assets/shared/countdown/jquery.countdown.min.js')!!}"></script>
</head>
<body>

    <div id="container">
        <h1>Site Offline</h1>

        <div>
            {!! Setting::value('offline_message') !!}
        </div>

        <!-- START COUNTDOWN -->
        <script src="{!! URL::to('assets/shared/countdown/countdown.js') !!}" type="text/javascript"></script>
        <?php 
$offline_end = Setting::value("{$link_type}_offline_end");
$offline_end = $offline_end ? Carbon\Carbon::createFromFormat('Y-m-d H:i:s', $offline_end) : '';
?>

        @if ($offline_end)
            <div>
                <h3>We'll be online in:</h3>
                <div id="countdown"></div>
            </div>

            <script type="application/javascript">

                $('#countdown').countdown({
                        until: new Date({!! $offline_end->year !!}, {!! $offline_end->month !!}-1, {!! $offline_end->day !!}, {!! $offline_end->hour !!}, {!! $offline_end->minute !!}, {!! $offline_end->second !!}),
                        onExpiry: reloadPage
                    });
示例#29
0
                        </thead>
                        <tbody>
                        <?php 
$items = $content->repeatableitems->order_by('timestamp DESC')->get();
foreach ($items as $item) {
    ?>
                            <tr>
                                <td><a href="<?php 
    echo site_url('administration/repeatables/edit/' . $item->id);
    ?>
"><?php 
    echo $item->title;
    ?>
</a></td>
								<td align="center"><?php 
    echo empty($item->timestamp) ? "&mdash;" : '<span class="tipN" title="' . date(Setting::value('datetime_format', 'F j, Y @ H:i'), $item->timestamp) . '">' . relative_time($item->timestamp) . '</span> ';
    ?>
</td>
                                <td align="center"><?php 
    echo $item->user->get()->name;
    ?>
</td>
                                <td class="actBtns">
									<a title="Edit" href="<?php 
    echo site_url('administration/repeatables/edit/' . $item->id);
    ?>
"  class="tipN"><img src="<?php 
    echo $template->base_url();
    ?>
images/icons/dark/pencil.png" alt=""></a>
									<a title="Remove" style="margin-left:2px !important" href="javascript:;" onclick="repeatable_remove(<?php 
示例#30
0
文件: Gallery.php 项目: jotavejv/CMS
 public function process_template($newdomitem, $i, $page, $content)
 {
     //$single = $this->_IU->input->get('read');
     $logged_in = !empty($this->_IU->user);
     //set title, and link it if it's <a> tag
     $titlefield = $newdomitem->find('.iu-gallery-title');
     foreach ($titlefield as $field) {
         $field->innertext = $i->title;
         if (strtolower(trim($field->tag)) == 'a') {
             $format = empty($field->{'data-format'}) ? '%page_url%?%read_slug%=%seo_title%' : (string) $field->{'data-format'};
             $seo_title = $i->id . '-' . cyr_url_title($i->title);
             $url = str_replace('%page_url%', site_url($page->uri), $format);
             $url = str_replace('%read_slug%', $this->read_slug, $url);
             $url = str_replace('%seo_title%', $seo_title, $url);
             $url = str_replace('%base_url%', base_url(), $url);
             $url = str_replace('%site_url%', site_url(), $url);
             $field->href = $url;
         }
     }
     //set link for <a> element; usable for "read more" links
     $itemlnks = $newdomitem->find('.iu-gallery-url');
     foreach ($itemlnks as $lnk) {
         if (strtolower(trim($lnk->tag)) != 'a') {
             continue;
         }
         $format = empty($lnk->{'data-format'}) ? '%page_url%?%read_slug%=%seo_title%' : (string) $lnk->{'data-format'};
         $seo_title = $i->id . '-' . cyr_url_title($i->title);
         $url = str_replace('%page_url%', site_url($page->uri), $format);
         $url = str_replace('%read_slug%', $this->read_slug, $url);
         $url = str_replace('%seo_title%', $seo_title, $url);
         $url = str_replace('%base_url%', base_url(), $url);
         $url = str_replace('%site_url%', site_url(), $url);
         $lnk->href = $url;
     }
     //fill out author name
     $authorfield = $newdomitem->find('.iu-gallery-author');
     foreach ($authorfield as $field) {
         $field->innertext = $i->user->get()->name;
     }
     //fill out text field
     $textfield = $newdomitem->find('.iu-gallery-text');
     foreach ($textfield as $field) {
         $limit = empty($field->{'data-limit'}) ? 0 : (int) $field->{'data-limit'};
         $field->innertext = $i->text;
     }
     //set images (and resize them)
     $images = $newdomitem->find('.iu-gallery-image');
     foreach ($images as $img) {
         if (strtolower(trim($img->tag)) != 'img') {
             continue;
         }
         $width = preg_replace('/[^0-9]+/', '', $img->width);
         if (empty($width)) {
             $width = 300;
         }
         $height = preg_replace('/[^0-9]+/', '', $img->height);
         if (empty($height)) {
             $height = 0;
         }
         $jackbox = empty($newdomitem->{'data-no-lightbox'}) ? true : false;
         $im = new Image($i->image);
         $img->src = $im->thumbnail($width, $height)->url;
         $img->setAttribute('data-fullimg', $im->uri);
         $img->alt = $img->title = $i->title;
         if ($jackbox) {
             $img->onclick = 'return iu_popup_gallery_image($(this));';
         }
         $img->id = 'iu_image_' . $i->id;
         $img->setAttribute('data-group', $content->div);
         $img->setAttribute('data-title', $i->title);
         $img->setAttribute('data-href', $i->image);
         $img->setAttribute('data-description', '#iu_gallery_desc_' . $i->id);
         /*$classesarr = empty($img->class) ? array() : explode(' ', $img->class);
         		$classesarr[] = 'iu-gallery-member';
         		$img->class = implode(' ', $classesarr); //*/
     }
     //set image links for <a> elements
     $imagelnks = $newdomitem->find('.iu-gallery-image-url');
     foreach ($imagelnks as $lnk) {
         if (strtolower(trim($lnk->tag)) != 'a') {
             continue;
         }
         if (!empty($i->image)) {
             $im = new Image($i->image);
             $lnk->href = $im->url;
         }
     }
     //set date
     $datefield = $newdomitem->find('.iu-gallery-date');
     foreach ($datefield as $field) {
         $format = empty($field->{'data-format'}) ? Setting::value('datetime_format', 'F j, Y @ H:i') : $field->{'data-format'};
         $field->innertext = date($format, $i->timestamp);
     }
     /*//add id
     		$idfield = $newdomitem->find('.iu-gallery-item-id', 0);
     		if (!empty($idfield))
     			$idfield->value = $i->id;
     		else
     			$newdomitem->innertext .= '<input type="hidden" class="iu-gallery-item-id" value="'.$i->id.'" />';
     
     		//add comments on single pages
     		/*$comments = Setting::value('comments_enabled', 'no');
     		if (($single !== false) && ($comments != 'no'))
     		{
     			$comments_engine = Setting::value('comments_engine_id', 'no');
     			if ($comments == 'Disqus')
     			{
     				$html = '<div id="disqus_thread"></div>';
     			}
     			else
     			{
     				$html = '<div style="text-align: center;" id="facebook_thread" class="fb-comments" data-href="'.site_url($page->uri).'?read='.$i->id.'-'.cyr_url_title($i->title).'" data-num-posts="2"></div>';
     			}
     
     			$newdomitem->innertext .= $html;
     		}//*/
     //add new item to placeholder
     return $newdomitem->outertext . "\n\n";
 }