示例#1
0
 public function delete()
 {
     $textMasterAPI = TextMasterAPI::getInstance();
     $result = $textMasterAPI->deleteProject($this->id_project_api);
     if (!is_array($result)) {
         return $result;
         // error
     }
     return TextMasterDocument::wipeProjectDocuments($this->id) && parent::delete();
 }
    die(Tools::jsonEncode(array('success' => true, 'project_price' => $price)));
} elseif (isset($_POST['get_document'])) {
    $messages = '';
    $id_document = Tools::getValue('id_document');
    $document = new TextMasterDocument($id_document);
    if (in_array($document->getStatus(), array('in_progress', 'in_review', 'incomplete'))) {
        Context::getContext()->smarty->assign('messages', $document->getComments());
        $messages = Context::getContext()->smarty->fetch(TEXTMASTER_TPL_DIR . 'admin/project/messages.tpl');
    }
    die(Tools::jsonEncode(array('api' => $document->getApiData(), 'id_document' => $id_document, 'comments' => $messages)));
} elseif (isset($_POST['submitComment'])) {
    $id_document = (int) Tools::getValue('id_document');
    if (!($message = pSQL(Tools::getValue('message')))) {
        $result = $module_instance->l('Comment cannot be empty', 'textmaster.ajax');
    } else {
        $document = new TextMasterDocument($id_document);
        $result = $document->comment($message);
    }
    if ($result === true) {
        Context::getContext()->smarty->assign('messages', $document->getComments());
        $messages = Context::getContext()->smarty->fetch(TEXTMASTER_TPL_DIR . 'admin/project/messages.tpl');
        die(Tools::jsonEncode(array('errors' => false, 'messages' => $messages)));
    } else {
        die(Tools::jsonEncode(array('errors' => true, 'error' => $result)));
    }
} elseif (Tools::isSubmit('getProductList')) {
    $id_category = (int) Tools::getValue('id_category');
    $order_link = Tools::getValue('order_url');
    $filter = Tools::getValue('filtering');
    $orderBy = '';
    $orderWay = '';
示例#3
0
 public function add($send_to_api = true, $null_values = false)
 {
     if ($send_to_api) {
         $textMasterAPI = new TextMasterAPI();
         $result = $textMasterAPI->addDocument($this->id_project_api, $this->api_data);
         if (is_array($result)) {
             $id_document_api = $result['id'];
             foreach ($this->api_data['original_content'] as $element => $text) {
                 $textMasterDocument = new TextMasterDocument();
                 $textMasterDocument->name = $element;
                 $textMasterDocument->id_product = (int) $this->api_data['id_product'];
                 $textMasterDocument->id_project = $this->id_project;
                 $textMasterDocument->id_document_api = $id_document_api;
                 if (!$textMasterDocument->add(false)) {
                     return false;
                 }
             }
         } else {
             return $result;
         }
         // error
     } else {
         return parent::add(true, false);
     }
     return true;
 }
示例#4
0
 private function displayResults()
 {
     $id_project = (int) Tools::getValue('id_project');
     $project = new TextMasterProject($id_project);
     $menu = Tools::getValue('menu', 'translation');
     if ($menu == 'proofreading') {
         $menu = $this->l('Proofreading projects');
     } elseif ($menu == 'copywriting') {
         $menu = $this->l('Copywriting projects');
     } else {
         $menu = $this->l('Translation projects');
     }
     /* menu and toolbar begin */
     /*required for new navigation (template)*/
     $this->context->smarty->assign(array('current_page_name' => $menu, 'current_inner_page_name' => $project->name));
     $this->displayNavigation();
     $statuses = array('in_creation' => $this->l('In creation'), 'waiting_assignment' => $this->l('Waiting assignment'), 'in_progress' => $this->l('In progress'), 'in_review' => $this->l('In review'), 'completed' => $this->l('Completed'), 'incomplete' => $this->l('Incomplete'), 'paused' => $this->l('Paused'), 'canceled' => $this->l('Cancelled'), 'copyscape' => $this->l('Copyscape'), 'counting_words' => $this->l('Counting_words'), 'quality_control' => $this->l('Quality control'));
     include_once _TEXTMASTER_CLASSES_DIR_ . 'project.view.php';
     $view = new TextMasterProjectView($this);
     //$helper = $view->initForm();
     $this->context->smarty->assign(array('project' => $project, 'documents' => TextMasterDocument::getDocuments($id_project, $project->id_project_api), 'view' => $view, 'statuses' => $statuses, 'module_url' => self::CURRENT_INDEX . Tools::getValue('token') . '&configure=' . $this->name . '&token=' . Tools::getAdminTokenLite('AdminModules') . "&menu=" . Tools::getValue('menu') . "&id_project=" . Tools::getValue('id_project') . "&viewproject", 'token' => sha1(_COOKIE_KEY_ . $this->name)));
     $this->_html .= $this->context->smarty->fetch(TEXTMASTER_TPL_DIR . 'admin/project/view.tpl');
 }