示例#1
0
 public function add_language()
 {
     $lng = trim($this->input->post('name'));
     $slg = $this->input->post('slug');
     if (empty($slg)) {
         $slg = cyr_url_title($lng);
         $slg = substr($slg, 0, 2);
     }
     $slg = trim($slg);
     $lang = Language::factory($lng);
     $lang->name = $lng;
     $lang->slug = $slg;
     $lang->active = 1;
     $lang->save();
     //get all phrases for default language
     $phrases = Language::get_default()->phrase->get();
     //copy all phrases for language to new language and clear translations
     foreach ($phrases as $phrase) {
         $newphr = $phrase->get_copy();
         $newphr->translation = null;
         $newphr->save(array($lang));
     }
     $this->update_languages_setting();
     redirect("administration/translations");
 }
示例#2
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");
 }
示例#3
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";
 }
示例#4
0
文件: images.php 项目: jotavejv/CMS
 private function do_save_from_pixlr($path = null)
 {
     $remote_img = $_GET['image'];
     $title = $_GET['title'];
     if (empty($path)) {
         $path = $this->user->assets_path();
     }
     if (empty($path)) {
         show_error("You can't save images on this website!");
     }
     if (!is_dir($path)) {
         @mkdir($path, 0777, true);
     }
     $fname = $check = cyr_url_title($title);
     $i = 1;
     while (is_file(FCPATH . $path . $check . '.jpg')) {
         $check = $fname . $i;
         $i++;
     }
     $fname = $check . '.jpg';
     //create file
     $f = new File();
     $f->path = ltrim($path . $fname, '/');
     $f->title = $title;
     $code = $this->http_get($remote_img);
     $ok = file_put_contents(FCPATH . $path . $fname, $code);
     $f->editor_id = $this->user->id;
     //if not written to a file, write to db
     if ($ok === FALSE) {
         $f->data = base64_encode($code);
         $f->checksum = md5($code);
         $f->save();
     }
     $ret = array();
     $ret['url'] = site_url($path . $fname);
     $ret['path'] = ltrim($path . $fname, '/');
     $ret['title'] = $title;
     return $ret;
 }
示例#5
0
 protected function slug()
 {
     if (isset($this->info['slug'])) {
         return $this->info['slug'];
     }
     $name = isset($this->info['name']) ? trim($this->info['name']) : false;
     if (empty($name)) {
         throw new PluginException("Plugin name not defined! Can not create slug!");
     }
     if (function_exists('cyr_url_title')) {
         return cyr_url_title($name);
     } else {
         return url_title($name, 'dash', true);
     }
 }
示例#6
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";
 }