예제 #1
0
파일: Photo_0.php 프로젝트: 62BRAINS/EPESI
 public function submit_attach($file, $oryg, $data, $record)
 {
     if (!$oryg) {
         $this->submitted = true;
         return;
     }
     /* check extension */
     $possible_extensions = array('jpg', 'jpeg', 'png');
     $extension = strtolower(end(explode('.', $oryg)));
     if (!in_array($extension, $possible_extensions)) {
         echo __('Filename extension should be one of these (letter size doesn\'t matter): ') . implode(', ', $possible_extensions);
         return;
     }
     if ($file) {
         $local = $this->get_data_dir();
         $filebase = md5($record['first_name'] . $record['last_name']) . $record['id'];
         $pattern = $local . $filebase;
         $i = 0;
         while (file_exists($pattern . $i . '.' . $extension)) {
             $i++;
         }
         $dest_file = $pattern . $i . '.' . $extension;
         $thumb = Utils_ImageCommon::create_thumb($file, 600, 600);
         @unlink($file);
         rename($thumb['thumb'], $dest_file);
         CRM_Contacts_PhotoCommon::add_photo($record['id'], $filebase . $i . '.' . $extension);
     }
     $this->submitted = true;
 }
예제 #2
0
파일: Image_0.php 프로젝트: cretzu89/EPESI
 public function body()
 {
     print '<table>';
     for ($row = 0; $row < 5; $row++) {
         print '<tr>';
         for ($column = 0; $column < 4; $column++) {
             $id = $row * 5 + $column + 1;
             print '<td>';
             //print_r($attr);
             Utils_ImageCommon::display_thumb("modules/Tests/Image/image_" . $id . ".jpg", 120);
             print '</td>';
         }
         print '</tr>';
     }
     print '</table>';
     //------------------------------ print out src
     print '<hr><b>Install</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Image/ImageInstall.php');
     print '<hr><b>Main</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Image/Image_0.php');
     print '<hr><b>Common</b><br>';
     $this->pack_module(Utils_CatFile::module_name(), 'modules/Tests/Image/ImageCommon_0.php');
 }
예제 #3
0
 public function download_template()
 {
     $ld = $this->get_data_dir() . 'list/';
     if (!file_exists($ld)) {
         return $this->download_templates_list();
     }
     if ($this->is_back()) {
         return false;
     }
     Base_ActionBarCommon::add('back', __('Back'), $this->create_back_href());
     Base_ActionBarCommon::add('search', __('Update templates list'), $this->create_callback_href(array($this, 'download_templates_list')));
     $m = $this->init_module(Utils_GenericBrowser::module_name(), null, 'new_templates');
     $m->set_table_columns(array(array('name' => 'Name', 'search' => 1), array('name' => 'Version'), array('name' => 'Screenshot'), array('name' => 'Author', 'search' => 1), array('name' => 'Info', 'search' => 1), array('name' => 'Compatible')));
     $content = scandir($ld);
     foreach ($content as $template_name) {
         if ($template_name == '.' || $template_name == '..') {
             continue;
         }
         $ini = parse_ini_file($ld . $template_name . '/info.ini');
         $compatible = version_compare($ini['epesi_version'], EPESI_VERSION) <= 0;
         $installed = is_dir(DATA_DIR . '/Base_Theme/templates/' . $template_name);
         if ($installed) {
             $installed_ini = @parse_ini_file(DATA_DIR . '/Base_Theme/templates/' . $template_name . '/info.ini');
             if (!$installed_ini) {
                 $installed_ini = array('version' => 0);
             }
         }
         if (isset($ini['screenshot'])) {
             $th_big = Utils_ImageCommon::create_thumb($ld . $template_name . '/' . $ini['screenshot'], 640, 480);
             $thumb = '<a href="' . $th_big['thumb'] . '" rel="lyteshow">' . Utils_ImageCommon::get_thumb_html($ld . $template_name . '/' . $ini['screenshot'], 120, 120) . '</a>';
         } else {
             $thumb = '';
         }
         $r = $m->get_new_row();
         $r->add_data($template_name, $ini['version'], $thumb, $ini['author'], $ini['info'], $compatible ? '<font color="green">yes</font>' : '<font color="red">NO</font> epesi ' . $ini['epesi_version'] . ' required');
         if ($compatible && !$installed) {
             $r->add_action($this->create_callback_href(array($this, 'install_template'), $template_name), 'Install');
         }
         if ($installed) {
             $r->add_action($this->create_callback_href(array($this, 'delete_template'), $template_name), 'Delete');
             if ($ini['version'] > $installed_ini['version']) {
                 $r->add_action($this->create_callback_href(array($this, 'update_template'), $template_name), 'Update');
             }
         }
     }
     $this->display_module($m, array(true), 'automatic_display');
     return true;
 }