예제 #1
2
    public static function getDocuments($id_project, $id_project_api)
    {
        $documents = array();
        $documents_db = Db::getInstance()->executeS('SELECT `id`, `id_document_api`, `id_product`
													 FROM `' . _DB_PREFIX_ . 'textmaster_document`
													 WHERE `id_project`="' . (int) $id_project . '"
													 GROUP BY `id_product`');
        $textMasterAPI = new TextMasterAPI();
        $documents_api = $textMasterAPI->getDocuments($id_project_api);
        if ($documents_db) {
            foreach ($documents_db as $row) {
                foreach ($documents_api['documents'] as &$document) {
                    if ($document['id'] == $row['id_document_api']) {
                        self::cleanDocumentContent($document);
                        $document['id_product'] = $row['id_product'];
                        $document['id'] = $row['id'];
                        $documents[] = $document;
                    }
                }
            }
        }
        return $documents;
    }
 public static function getInstance($module_instance = null, $api_key = null, $api_secret = null)
 {
     if (!self::$instance) {
         self::$instance = new TextMasterAPI($module_instance, $api_key, $api_secret);
     }
     return self::$instance;
 }
예제 #3
0
 function __construct($module_instance)
 {
     if (!$module_instance) {
         exit;
     }
     $this->module_instance = $module_instance;
     $this->context = Context::getContext();
     $this->settings_obj = new TextMasterConfiguration();
     $this->textmasterAPI = TextMasterAPI::getInstance($module_instance, $this->settings_obj->api_key, $this->settings_obj->api_secret);
     $this->tpl_dir = TEXTMASTER_TPL_DIR . 'admin/';
 }
예제 #4
0
 public function quote()
 {
     $textMasterAPI = TextMasterAPI::getInstance();
     $result = $textMasterAPI->addProject($this->api_data, true);
     if (is_array($result) && isset($result['total_costs'])) {
         $user_info = $textMasterAPI->getUserInfo();
         foreach ($result['total_costs'] as $costs) {
             if ($costs['currency'] == $user_info['wallet']['currency_code']) {
                 // looks for the correct currency
                 return $costs['amount'] . ' ' . $costs['currency'];
             }
         }
     }
     return $result;
 }
예제 #5
0
 public function getAPIConnection()
 {
     if ($this->api_instance) {
         return $this->api_instance;
     }
     $api_key = TextMasterConfiguration::get('api_key');
     $api_secret = TextMasterConfiguration::get('api_secret');
     /* checks connection to API if at least one of API codes is set */
     if ($api_key or $api_secret) {
         $textmasterAPI = new TextMasterAPI($this, $api_key, $api_secret);
         if (!$textmasterAPI->isConnected()) {
             $this->_html .= $this->displayWarnings(array($this->l('Please login / register')));
             return false;
         }
     } else {
         return false;
     }
     $this->api_instance = $textmasterAPI;
     return $this->api_instance;
 }
예제 #6
0
 private function displayProjectCreationForm()
 {
     if (Tools::isSubmit('submitFilterdocument') && Tools::getValue('pagination')) {
         $_GET['submitFilterdocument'] = Tools::getValue('submitFilterdocument');
         $_GET['pagination'] = Tools::getValue('pagination');
     }
     $id_project = Tools::getvalue('id_project', 0);
     $steps = array('products' => 0, 'properties' => 1, 'summary' => 2);
     $current_step = Tools::getValue('step', 'products');
     /* creates space for project data in the first step */
     if ($current_step == 'products' && !$this->textmaster_data_with_cookies_manager_obj->projectExists()) {
         $this->textmaster_data_with_cookies_manager_obj->setAllProject(array());
         $this->textmaster_data_with_cookies_manager_obj->setProjectField('project_step', '');
     }
     /* project creation form begin */
     include_once _TEXTMASTER_CLASSES_DIR_ . 'project.view.php';
     $view = new TextMasterProjectView($this);
     /* project creation form end */
     switch ($current_step) {
         case 'products':
             $view->getProductsSelectForm();
             $view->getProductsSelectedProductsForm();
             break;
         case 'properties':
             if (version_compare(_PS_VERSION_, '1.5', '<')) {
                 if (version_compare(_PS_VERSION_, '1.5', '<')) {
                     echo '<link href="' . $this->_path . 'css/product.css" rel="stylesheet" type="text/css">';
                 } else {
                     $this->context->controller->addCSS($this->_path . 'css/product.css', 'all');
                 }
             }
             $view->getProjectProperties();
             break;
         case 'summary':
             $view->getProjectSummary();
             break;
     }
     $textmasterAPI = TextMasterAPI::getInstance($this);
     $this->context->smarty->assign(array('textmaster_token' => sha1(_COOKIE_KEY_ . $this->name), 'view' => $view, 'module_link' => self::CURRENT_INDEX . Tools::getValue('token') . '&configure=' . $this->name . '&menu=create_project&token=' . Tools::getValue('token') . ($id_project ? "&id_project={$id_project}" : ''), 'steps' => $steps, 'id_lang' => $this->context->language->id, 'project_step' => $this->textmaster_data_with_cookies_manager_obj->getProjectData('project_step'), 'authors' => $textmasterAPI->authors['my_authors']));
     $this->_html .= $this->context->smarty->fetch(TEXTMASTER_TPL_DIR . 'admin/project/index.tpl');
 }