コード例 #1
0
/**
 * Smarty function
 * -------------------------------------------------------------
 * Purpose: Output multilang string
 * add [{ oxmultilang ident="..." }] where you want to display content
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param Smarty &$smarty clever simulation of a method
 *
 * @return string
*/
function smarty_function_oxmultilang($params, &$smarty)
{
    startProfile("smarty_function_oxmultilang");
    $sIdent = isset($params['ident']) ? $params['ident'] : 'IDENT MISSING';
    $iLang = null;
    $blAdmin = isAdmin();
    $oLang = oxLang::getInstance();
    if ($blAdmin) {
        $iLang = $oLang->getTplLanguage();
        if (!isset($iLang)) {
            $iLang = 0;
        }
    }
    try {
        $sTranslation = $oLang->translateString($sIdent, $iLang, $blAdmin);
    } catch (oxLanguageException $oEx) {
        // is thrown in debug mode and has to be caught here, as smarty hangs otherwise!
    }
    if ($blAdmin && $sTranslation == $sIdent && (!isset($params['noerror']) || !$params['noerror'])) {
        $sTranslation = '<b>ERROR : Translation for ' . $sIdent . ' not found!</b>';
    }
    if ($sTranslation == $sIdent && isset($params['alternative'])) {
        $sTranslation = $params['alternative'];
    }
    stopProfile("smarty_function_oxmultilang");
    return $sTranslation;
}
コード例 #2
0
 protected function _checkAuthorization()
 {
     startProfile('ChromePHP: ' . __CLASS__ . ' / ' . __FUNCTION__);
     if ($this->_getAuthorization()->getAuthorization()) {
         $this->_enableChrome();
     }
     stopProfile('ChromePHP: ' . __CLASS__ . ' / ' . __FUNCTION__);
 }
コード例 #3
0
 /**
  * Includes file, where given class is described.
  *
  * @param string $class Class Name
  */
 public function autoload($class)
 {
     startProfile("ShopAutoload");
     $class = strtolower(basename($class));
     if ($classPath = $this->getClassPath($class)) {
         include $classPath;
     }
     stopProfile("ShopAutoload");
 }
コード例 #4
0
 /**
  * Fetches raw categories and does postprocessing for adding depth information.
  *
  * @param string $id
  */
 public function buildActCatList($id)
 {
     $this->setActCat($id);
     startProfile('buildCategoryList');
     $this->_blForceFull = false;
     $this->_blHideEmpty = false;
     $sql = $this->_getSelectString(false);
     $this->selectString($sql);
     stopProfile('buildCategoryList');
 }
コード例 #5
0
 /**
  * Returns new seo url including the model no.
  *
  *
  * @param oxArticle  $oArticle  article object
  * @param oxCategory $oCategory category object
  * @param int        $iLang     language to generate uri for
  *
  * @return string
  */
 protected function _createArticleCategoryUri($oArticle, $oCategory, $iLang)
 {
     startProfile(__FUNCTION__);
     $oArticle = $this->_getProductForLang($oArticle, $iLang);
     // create title part for uri
     $sTitle = $this->_prepareArticleTitle($oArticle);
     $sTitle = str_replace($this->_getUrlExtension(), " " . $oArticle->oxarticles__oxartnum->value, $sTitle) . "." . $this->_getUrlExtension();
     // writing category path
     $sSeoUri = $this->_processSeoUrl($sTitle, $oArticle->getId(), $iLang);
     $sCatId = $oCategory->getId();
     $this->_saveToDb('oxarticle', $oArticle->getId(), oxUtilsUrl::getInstance()->appendUrl($oArticle->getBaseStdLink($iLang), array('cnid' => $sCatId)), $sSeoUri, $iLang, null, 0, $sCatId);
     stopProfile(__FUNCTION__);
     return $sSeoUri;
 }
コード例 #6
0
 /**
  * Tries to autoload given class. If class was not found in module files array,
  * checks module extensions.
  *
  * @param string $class Class name.
  */
 public function autoload($class)
 {
     startProfile("oxModuleAutoload");
     $class = strtolower(basename($class));
     if ($classPath = $this->getFilePath($class)) {
         include $classPath;
     } else {
         $class = preg_replace('/_parent$/i', '', $class);
         if (!in_array($class, $this->triedClasses)) {
             $this->triedClasses[] = $class;
             $this->createExtensionClassChain($class);
         }
     }
     stopProfile("oxModuleAutoload");
 }
コード例 #7
0
/**
 * Smarty function
 * -------------------------------------------------------------
 * Purpose: Output multilang string
 * add [{ oxmultilang ident="..." args=... }] where you want to display content
 * ident - language constant
 * args - array of argument that can be parsed to language constant threw %s
 * -------------------------------------------------------------
 *
 * @param array  $params  params
 * @param Smarty &$smarty clever simulation of a method
 *
 * @return string
*/
function smarty_function_oxmultilang($params, &$smarty)
{
    startProfile("smarty_function_oxmultilang");
    $oLang = oxRegistry::getLang();
    $oConfig = oxRegistry::getConfig();
    $oShop = $oConfig->getActiveShop();
    $blAdmin = $oLang->isAdmin();
    $sIdent = isset($params['ident']) ? $params['ident'] : 'IDENT MISSING';
    $aArgs = isset($params['args']) ? $params['args'] : false;
    $sSuffix = isset($params['suffix']) ? $params['suffix'] : 'NO_SUFFIX';
    $blShowError = isset($params['noerror']) ? !$params['noerror'] : true;
    $iLang = $oLang->getTplLanguage();
    if (!$blAdmin && $oShop->isProductiveMode()) {
        $blShowError = false;
    }
    try {
        $sTranslation = $oLang->translateString($sIdent, $iLang, $blAdmin);
        $blTranslationNotFound = !$oLang->isTranslated();
        if ('NO_SUFFIX' != $sSuffix) {
            $sSuffixTranslation = $oLang->translateString($sSuffix, $iLang, $blAdmin);
        }
    } catch (oxLanguageException $oEx) {
        // is thrown in debug mode and has to be caught here, as smarty hangs otherwise!
    }
    if ($blTranslationNotFound && isset($params['alternative'])) {
        $sTranslation = $params['alternative'];
        $blTranslationNotFound = false;
    }
    if (!$blTranslationNotFound) {
        if ($aArgs !== false) {
            if (is_array($aArgs)) {
                $sTranslation = vsprintf($sTranslation, $aArgs);
            } else {
                $sTranslation = sprintf($sTranslation, $aArgs);
            }
        }
        if ('NO_SUFFIX' != $sSuffix) {
            $sTranslation .= $sSuffixTranslation;
        }
    } elseif ($blShowError) {
        $sTranslation = 'ERROR: Translation for ' . $sIdent . ' not found!';
    }
    stopProfile("smarty_function_oxmultilang");
    return $sTranslation;
}
コード例 #8
0
 public function selectString($sSql, $values = array())
 {
     startProfile("loadinglists");
     $this->clear();
     $oDb = oxDb::getDb(oxDb::FETCH_MODE_ASSOC);
     if ($this->_aSqlLimit[0] || $this->_aSqlLimit[1]) {
         $rs = $oDb->selectLimit($sSql, $this->_aSqlLimit[1], $this->_aSqlLimit[0], $values);
     } else {
         $rs = $oDb->select($sSql, $values);
     }
     if ($rs != false && $rs->recordCount() > 0) {
         $oSaved = clone $this->getBaseObject();
         while (!$rs->EOF) {
             $oListObject = clone $oSaved;
             $this->_assignElement($oListObject, $rs->fields);
             $this->add($oListObject);
             $rs->moveNext();
         }
     }
     stopProfile("loadinglists");
 }
コード例 #9
0
/**
 * Creates and returns new object. If creation is not available, dies and outputs
 * error message.
 *
 * @param string $className Name of class
 * @param mixed ...$args constructor arguments
 * @throws oxSystemComponentException in case that class does not exists
 *
 * @return object
 */
function oxNew($className)
{
    startProfile('oxNew');
    $arguments = func_get_args();
    $object = call_user_func_array(array(oxUtilsObject::getInstance(), "oxNew"), $arguments);
    stopProfile('oxNew');
    return $object;
}
コード例 #10
0
/**
 * Creates and returns new object. If creation is not available, dies and outputs
 * error message.
 *
 * @param string $sClassName Name of class
 *
 * @throws oxSystemComponentException in case that class does not exists
 *
 * @return object
 */
function oxNew($sClassName)
{
    startProfile('oxNew');
    $aArgs = func_get_args();
    $oRes = call_user_func_array(array(oxUtilsObject::getInstance(), "oxNew"), $aArgs);
    stopProfile('oxNew');
    return $oRes;
}
コード例 #11
0
 /**
  * get VAT for given article, can NOT be null
  *
  * @param Article $oArticle given article
  *
  * @return double
  */
 public function getArticleVat(Article $oArticle)
 {
     startProfile("_assignPriceInternal");
     // article has its own VAT ?
     if (($dArticleVat = $oArticle->getCustomVAT()) !== null) {
         stopProfile("_assignPriceInternal");
         return $dArticleVat;
     }
     if (($dArticleVat = $this->_getVatForArticleCategory($oArticle)) !== false) {
         stopProfile("_assignPriceInternal");
         return $dArticleVat;
     }
     stopProfile("_assignPriceInternal");
     return $this->getConfig()->getConfigParam('dDefaultVAT');
 }
コード例 #12
0
ファイル: oxutilsview.php プロジェクト: ioanok/symfoxid
 /**
  * Runs long description through smarty. If you pass array of data
  * to process, array will be returned, if you pass string - string
  * will be passed as result
  *
  * @param mixed  $sDesc       description or array of descriptions ( array( [] => array( _ident_, _value_to_process_ ) ) )
  * @param string $sOxid       current object id
  * @param oxview $oActView    view data to use its view data (optional)
  * @param bool   $blRecompile force to recompile if found in cache
  *
  * @return mixed
  */
 public function parseThroughSmarty($sDesc, $sOxid = null, $oActView = null, $blRecompile = false)
 {
     if (oxRegistry::getConfig()->isDemoShop()) {
         return $sDesc;
     }
     startProfile("parseThroughSmarty");
     if (!is_array($sDesc) && strpos($sDesc, "[{") === false) {
         stopProfile("parseThroughSmarty");
         return $sDesc;
     }
     $iLang = oxRegistry::getLang()->getTplLanguage();
     // now parse it through smarty
     $oSmarty = clone $this->getSmarty();
     // save old tpl data
     $sTplVars = $oSmarty->_tpl_vars;
     $blForceRecompile = $oSmarty->force_compile;
     $oSmarty->force_compile = $blRecompile;
     if (!$oActView) {
         $oActView = oxNew('oxubase');
         $oActView->addGlobalParams();
     }
     $aViewData = $oActView->getViewData();
     foreach (array_keys($aViewData) as $sName) {
         $oSmarty->assign_by_ref($sName, $aViewData[$sName]);
     }
     if (is_array($sDesc)) {
         foreach ($sDesc as $sName => $aData) {
             $oSmarty->oxidcache = new oxField($aData[1], oxField::T_RAW);
             $sRes[$sName] = $oSmarty->fetch("ox:" . $aData[0] . $iLang);
         }
     } else {
         $oSmarty->oxidcache = new oxField($sDesc, oxField::T_RAW);
         $sRes = $oSmarty->fetch("ox:{$sOxid}{$iLang}");
     }
     // restore tpl vars for continuing smarty processing if it is in one
     $oSmarty->_tpl_vars = $sTplVars;
     $oSmarty->force_compile = $blForceRecompile;
     stopProfile("parseThroughSmarty");
     return $sRes;
 }
コード例 #13
0
 /**
  * Returns current view config parameter
  *
  * @param string $sName name of parameter to get
  *
  * @return mixed
  */
 public function getViewConfigParam($sName)
 {
     startProfile('oxviewconfig::getViewConfigParam');
     if ($this->_oShop && isset($this->_oShop->{$sName})) {
         $sValue = $this->_oShop->{$sName};
     } elseif ($this->_aViewData && isset($this->_aViewData[$sName])) {
         $sValue = $this->_aViewData[$sName];
     } else {
         $sValue = isset($this->_aConfigParams[$sName]) ? $this->_aConfigParams[$sName] : null;
     }
     stopProfile('oxviewconfig::getViewConfigParam');
     return $sValue;
 }
コード例 #14
0
 /**
  * Loads articles, that price is bigger than passed $dPriceFrom and smaller
  * than passed $dPriceTo. Returns count of selected articles.
  *
  * @param double $dPriceFrom Price from
  * @param double $dPriceTo   Price to
  * @param object $oCategory  Active category object
  *
  * @return integer
  */
 public function loadPriceArticles($dPriceFrom, $dPriceTo, $oCategory = null)
 {
     $sSelect = $this->_getPriceSelect($dPriceFrom, $dPriceTo);
     startProfile("loadPriceArticles");
     $this->selectString($sSelect);
     stopProfile("loadPriceArticles");
     if (!$oCategory) {
         return $this->count();
     }
     return oxRegistry::get("oxUtilsCount")->getPriceCatArticleCount($oCategory->getId(), $dPriceFrom, $dPriceTo);
 }
コード例 #15
0
 /**
  * Fetches raw categories and does postprocessing for adding depth information
  */
 public function loadList()
 {
     startProfile('buildCategoryList');
     $this->setLoadFull(true);
     $this->selectString($this->_getSelectString(false, null, 'oxparentid, oxsort, oxtitle'));
     // build tree structure
     $this->_ppBuildTree();
     // PostProcessing
     // add tree depth info
     $this->_ppAddDepthInformation();
     stopProfile('buildCategoryList');
 }
コード例 #16
0
ファイル: Base.php プロジェクト: Crease29/oxideshop_ce
 /**
  * Returns the list of fields. This function is slower and its result is normally cached.
  * Basically we have 3 separate cases here:
  *  1. We are in admin so we need extended info for all fields (name, field length and field type)
  *  2. Object is not lazy loaded so we will return all data fields as simple array, as we need only names
  *  3. Object is lazy loaded so we will return empty array as all fields are loaded on request (in __get()).
  *
  * @param bool $forceFullStructure Whether to force loading of full data structure
  *
  * @return array
  */
 protected function _getNonCachedFieldNames($forceFullStructure = false)
 {
     //T2008-02-22
     //so if this method is executed on cached version we see it when profiling
     startProfile('!__CACHABLE__!');
     //case 1. (admin)
     if ($this->isAdmin()) {
         $metaFields = $this->_getAllFields();
         foreach ($metaFields as $oneField) {
             if ($oneField->max_length == -1) {
                 $oneField->max_length = 10;
                 // double or float
             }
             if ($oneField->type == 'datetime') {
                 $oneField->max_length = 20;
             }
             $this->_addField($oneField->name, $this->_getFieldStatus($oneField->name), $oneField->type, $oneField->max_length);
         }
         stopProfile('!__CACHABLE__!');
         return false;
     }
     //case 2. (just get all fields)
     if ($forceFullStructure || !$this->_blUseLazyLoading) {
         $metaFields = $this->_getAllFields(true);
         /*
                     foreach ( $aMetaFields as $sFieldName => $sVal) {
                         $this->_addField( $sFieldName, $this->_getFieldStatus($sFieldName));
                     }*/
         stopProfile('!__CACHABLE__!');
         return $metaFields;
     }
     //case 3. (get only oxid field, so we can fetch the rest of the fields over lazy loading mechanism)
     stopProfile('!__CACHABLE__!');
     return array('oxid' => 0);
 }
コード例 #17
0
ファイル: I18n.php プロジェクト: Crease29/oxideshop_ce
 /**
  * Checks if this field is multlingual
  * (returns false if language = 0)
  *
  * @param string $sFieldName Field name
  *
  * @return bool
  */
 public function isMultilingualField($sFieldName)
 {
     $sFieldName = strtolower($sFieldName);
     if (isset($this->_aFieldNames[$sFieldName])) {
         return (bool) $this->_aFieldNames[$sFieldName];
     }
     //not inited field yet
     //and note that this is should be called only in first call after tmp dir is empty
     startProfile('!__CACHABLE2__!');
     $blIsMultilang = (bool) $this->_getFieldStatus($sFieldName);
     stopProfile('!__CACHABLE2__!');
     return (bool) $blIsMultilang;
 }
コード例 #18
0
ファイル: Utils.php プロジェクト: Alpha-Sys/oxideshop_ce
 /**
  * Writes all cache contents to file at once. This method was introduced due to possible
  * race conditions. Cache is cleaned up after commit
  */
 public function commitFileCache()
 {
     if (!empty($this->_aLockedFileHandles[LOCK_EX])) {
         startProfile("!__SAVING CACHE__! (warning)");
         foreach ($this->_aLockedFileHandles[LOCK_EX] as $sKey => $rHandle) {
             if ($rHandle !== false && isset($this->_aFileCacheContents[$sKey])) {
                 // #0002931A truncate file once more before writing
                 ftruncate($rHandle, 0);
                 // writing cache
                 fwrite($rHandle, $this->_processCache($sKey, $this->_aFileCacheContents[$sKey]));
                 // releasing locks
                 $this->_releaseFile($sKey);
             }
         }
         stopProfile("!__SAVING CACHE__! (warning)");
         //empty buffer
         $this->_aFileCacheContents = array();
     }
 }
コード例 #19
0
ファイル: oxarticle.php プロジェクト: Crease29/oxideshop_ce
 /**
  * Assigns parent field values to article
  */
 protected function _assignParentFieldValues()
 {
     startProfile('articleAssignParentInternal');
     if ($this->oxarticles__oxparentid->value) {
         // yes, we are in fact a variant
         if (!$this->isAdmin() || $this->_blLoadParentData && $this->isAdmin()) {
             foreach ($this->_aFieldNames as $sFieldName => $sVal) {
                 $this->_assignParentFieldValue($sFieldName);
             }
         }
     }
     stopProfile('articleAssignParentInternal');
 }
コード例 #20
0
ファイル: ShopControl.php プロジェクト: Crease29/oxideshop_ce
 /**
  * Executes regular maintenance functions..
  *
  * @return null
  */
 protected function _executeMaintenanceTasks()
 {
     if (isset($this->_blMainTasksExecuted)) {
         return;
     }
     startProfile('executeMaintenanceTasks');
     oxNew("oxArticleList")->updateUpcomingPrices();
     stopProfile('executeMaintenanceTasks');
 }
コード例 #21
0
ファイル: oxlang.php プロジェクト: mibexx/oxid_yttutorials
 /**
  * get language array from lang translation file
  *
  * @param int   $iLang      optional language
  * @param bool  $blAdmin    admin mode switch
  * @param array $aLangFiles language files to load [optional]
  *
  * @return array
  */
 protected function _getLangTranslationArray($iLang = null, $blAdmin = null, $aLangFiles = null)
 {
     startProfile("_getLangTranslationArray");
     $blAdmin = isset($blAdmin) ? $blAdmin : $this->isAdmin();
     $iLang = $this->_getCacheLanguageId($blAdmin, $iLang);
     $sCacheName = $this->_getLangFileCacheName($blAdmin, $iLang, $aLangFiles);
     if (!isset($this->_aLangCache[$sCacheName])) {
         $this->_aLangCache[$sCacheName] = array();
     }
     if (!isset($this->_aLangCache[$sCacheName][$iLang])) {
         // loading main lang files data
         $this->_aLangCache[$sCacheName][$iLang] = $this->_getLanguageFileData($blAdmin, $iLang, $aLangFiles);
     }
     stopProfile("_getLangTranslationArray");
     // if language array exists ..
     return isset($this->_aLangCache[$sCacheName][$iLang]) ? $this->_aLangCache[$sCacheName][$iLang] : array();
 }
コード例 #22
0
 /**
  * type dependant image resizing
  *
  * @param array  $aImageInfo        Contains information on image's type / width / height
  * @param string $sSrc              source image
  * @param string $hDestinationImage Destination Image
  * @param string $sTarget           Resized Image target
  * @param int    $iNewWidth         Resized Image's width
  * @param int    $iNewHeight        Resized Image's height
  * @param mixed  $iGdVer            used GDVersion, if null or false returns false
  * @param bool   $blDisableTouch    false if "touch()" should be called for gif resizing
  * @param string $iDefQuality       quality for "imagejpeg" function
  *
  * @return bool
  */
 protected function _resize($aImageInfo, $sSrc, $hDestinationImage, $sTarget, $iNewWidth, $iNewHeight, $iGdVer, $blDisableTouch, $iDefQuality)
 {
     startProfile("PICTURE_RESIZE");
     $blSuccess = false;
     switch ($aImageInfo[2]) {
         //Image type
         case $this->_aImageTypes["GIF"]:
             //php does not process gifs until 7th July 2004 (see lzh licensing)
             if (function_exists("imagegif")) {
                 $blSuccess = resizeGif($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo[0], $aImageInfo[1], $iGdVer);
             }
             break;
         case $this->_aImageTypes["JPEG"]:
         case $this->_aImageTypes["JPG"]:
             $blSuccess = resizeJpeg($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage, $iDefQuality);
             break;
         case $this->_aImageTypes["PNG"]:
             $blSuccess = resizePng($sSrc, $sTarget, $iNewWidth, $iNewHeight, $aImageInfo, $iGdVer, $hDestinationImage);
             break;
     }
     if ($blSuccess && !$blDisableTouch) {
         @touch($sTarget);
     }
     stopProfile("PICTURE_RESIZE");
     return $blSuccess;
 }
コード例 #23
0
 /**
  * get recommendation lists wich include given article ids
  * also sort these lists by these criterias:
  *     1. show lists, that has more requested articles first
  *     2. show lists, that have more any articles
  *
  * @param array $aArticleIds Object IDs
  *
  * @return oxList
  */
 public function getRecommListsByIds($aArticleIds)
 {
     if (count($aArticleIds)) {
         startProfile(__FUNCTION__);
         $sIds = implode(",", oxDb::getInstance()->quoteArray($aArticleIds));
         $oRecommList = oxNew('oxlist');
         $oRecommList->init('oxrecommlist');
         $iShopId = $this->getConfig()->getShopId();
         $iCnt = $this->getConfig()->getConfigParam('iNrofCrossellArticles');
         $oRecommList->setSqlLimit(0, $iCnt);
         $sSelect = "SELECT distinct lists.* FROM oxobject2list AS o2l_lists";
         $sSelect .= " LEFT JOIN oxobject2list AS o2l_count ON o2l_lists.oxlistid = o2l_count.oxlistid";
         $sSelect .= " LEFT JOIN oxrecommlists as lists ON o2l_lists.oxlistid = lists.oxid";
         $sSelect .= " WHERE o2l_lists.oxobjectid IN ( {$sIds} ) and lists.oxshopid ='{$iShopId}'";
         $sSelect .= " GROUP BY lists.oxid order by (";
         $sSelect .= " SELECT count( order1.oxobjectid ) FROM oxobject2list AS order1";
         $sSelect .= " WHERE order1.oxobjectid IN ( {$sIds} ) AND o2l_lists.oxlistid = order1.oxlistid";
         $sSelect .= " ) DESC, count( lists.oxid ) DESC";
         $oRecommList->selectString($sSelect);
         stopProfile(__FUNCTION__);
         if ($oRecommList->count()) {
             startProfile('_loadFirstArticles');
             $this->_loadFirstArticles($oRecommList, $aArticleIds);
             stopProfile('_loadFirstArticles');
             return $oRecommList;
         }
     }
 }
コード例 #24
0
 /**
  * Fetches raw categories and does postprocessing for adding depth information
  *
  * @param bool $blLoad usually used with config option bl_perfLoadCatTree
  *
  * @return null
  */
 public function buildList($blLoad)
 {
     if (!$blLoad) {
         return;
     }
     startProfile('buildCategoryList');
     $this->_blForceFull = true;
     $this->selectString($this->_getSelectString(false));
     // build tree structure
     $this->_ppBuildTree();
     // PostProcessing
     // add tree depth info
     $this->_ppAddDepthInformation();
     stopProfile('buildCategoryList');
 }
コード例 #25
0
ファイル: oxubase.php プロジェクト: mibexx/oxid_yttutorials
 /**
  * Generates variables for page navigation
  *
  * @param int $iPositionCount - paging positions count ( 0 - unlimited )
  *
  * @return  stdClass    $pageNavigation Object with page navigation data
  */
 public function generatePageNavigation($iPositionCount = 0)
 {
     startProfile('generatePageNavigation');
     $pageNavigation = new stdClass();
     $pageNavigation->NrOfPages = $this->_iCntPages;
     $iActPage = $this->getActPage();
     $pageNavigation->actPage = $iActPage + 1;
     $sUrl = $this->generatePageNavigationUrl();
     if ($iPositionCount == 0 || $iPositionCount >= $pageNavigation->NrOfPages) {
         $iStartNo = 2;
         $iFinishNo = $pageNavigation->NrOfPages;
     } else {
         $iTmpVal = $iPositionCount - 3;
         $iTmpVal2 = floor(($iPositionCount - 4) / 2);
         // actual page is at the start
         if ($pageNavigation->actPage <= $iTmpVal) {
             $iStartNo = 2;
             $iFinishNo = $iTmpVal + 1;
             // actual page is at the end
         } elseif ($pageNavigation->actPage >= $pageNavigation->NrOfPages - $iTmpVal) {
             $iStartNo = $pageNavigation->NrOfPages - $iTmpVal;
             $iFinishNo = $pageNavigation->NrOfPages - 1;
             // actual page is in the middle
         } else {
             $iStartNo = $pageNavigation->actPage - $iTmpVal2;
             $iFinishNo = $pageNavigation->actPage + $iTmpVal2;
         }
     }
     if ($iActPage > 0) {
         $pageNavigation->previousPage = $this->_addPageNrParam($sUrl, $iActPage - 1);
     }
     if ($iActPage < $pageNavigation->NrOfPages - 1) {
         $pageNavigation->nextPage = $this->_addPageNrParam($sUrl, $iActPage + 1);
     }
     if ($pageNavigation->NrOfPages > 1) {
         for ($i = 1; $i < $pageNavigation->NrOfPages + 1; $i++) {
             if ($i == 1 || $i == $pageNavigation->NrOfPages || $i >= $iStartNo && $i <= $iFinishNo) {
                 $page = new stdClass();
                 $page->url = $this->_addPageNrParam($sUrl, $i - 1);
                 $page->selected = $i == $pageNavigation->actPage ? 1 : 0;
                 $pageNavigation->changePage[$i] = $page;
             }
         }
         // first/last one
         $pageNavigation->firstpage = $this->_addPageNrParam($sUrl, 0);
         $pageNavigation->lastpage = $this->_addPageNrParam($sUrl, $pageNavigation->NrOfPages - 1);
     }
     stopProfile('generatePageNavigation');
     return $pageNavigation;
 }
コード例 #26
0
 /**
  * Initiates object (object::init()), executes passed function
  * (oxShopControl::executeFunction(), if method returns some string - will
  * redirect page and will call another function according to returned
  * parameters), renders object (object::render()). Performs output processing
  * oxOutput::ProcessViewArray(). Passes template variables to template
  * engine witch generates output. Output is additionally processed
  * (oxOutput::Process()), fixed links according search engines optimization
  * rules (configurable in Admin area). Finally echoes the output.
  *
  * @param string $sClass    Name of class
  * @param string $sFunction Name of function
  *
  * @return null
  */
 protected function _process($sClass, $sFunction)
 {
     startProfile('process');
     $myConfig = $this->getConfig();
     $myUtils = oxUtils::getInstance();
     $sViewID = null;
     if (!$myUtils->isSearchEngine() && !($this->isAdmin() || !$myConfig->getConfigParam('blLogging'))) {
         $this->_log($sClass, $sFunction);
     }
     // starting resource monitor
     $this->_startMonitor();
     // caching params ...
     $sOutput = null;
     $blIsCached = false;
     $oViewObject = $this->_initializeViewObject($sClass, $sFunction);
     // executing user defined function
     $oViewObject->executeFunction($oViewObject->getFncName());
     // if no cache was stored before we should generate it
     if (!$blIsCached) {
         $sOutput = $this->_render($oViewObject);
     }
     $oOutput = $this->_getOutputManager();
     $oOutput->setCharset($oViewObject->getCharSet());
     if (oxConfig::getParameter('renderPartial')) {
         $oOutput->setOutputFormat(oxOutput::OUTPUT_FORMAT_JSON);
         $oOutput->output('errors', $this->_getFormattedErrors());
     }
     $oOutput->sendHeaders();
     $oOutput->output('content', $sOutput);
     $myConfig->pageClose();
     stopProfile('process');
     // stopping resource monitor
     $this->_stopMonitor($oViewObject->getIsCallForCache(), $blIsCached, $sViewID, $oViewObject->getViewData());
     // flush output (finalize)
     $oOutput->flushOutput();
 }
コード例 #27
0
 /**
  * getDynamicUrl acts similar to static urls,
  * except, that dynamic url are not shown in admin
  * and they can be reencoded by providing new seo url
  *
  * @param string $sStdUrl standard url
  * @param string $sSeoUrl part of URL query which will be attached to standard shop url
  * @param int    $iLang   active language
  *
  * @access public
  *
  * @return string
  */
 public function getDynamicUrl($sStdUrl, $sSeoUrl, $iLang)
 {
     startProfile("getDynamicUrl");
     $sDynUrl = $this->_getFullUrl($this->_getDynamicUri($sStdUrl, $sSeoUrl, $iLang), strpos($sStdUrl, "https:") === 0);
     stopProfile("getDynamicUrl");
     return $sDynUrl;
 }
コード例 #28
0
ファイル: oxshopcontrol.php プロジェクト: ioanok/symfoxid
 /**
  * Initiates object (object::init()), executes passed function
  * (oxShopControl::executeFunction(), if method returns some string - will
  * redirect page and will call another function according to returned
  * parameters), renders object (object::render()). Performs output processing
  * oxOutput::ProcessViewArray(). Passes template variables to template
  * engine witch generates output. Output is additionally processed
  * (oxOutput::Process()), fixed links according search engines optimization
  * rules (configurable in Admin area). Finally echoes the output.
  *
  * @param string $sClass      Name of class
  * @param string $sFunction   Name of function
  * @param array  $aParams     Parameters array
  * @param array  $aViewsChain Array of views names that should be initialized also
  */
 protected function _process($sClass, $sFunction, $aParams = null, $aViewsChain = null)
 {
     startProfile('process');
     $myConfig = $this->getConfig();
     // executing maintenance tasks
     $this->_executeMaintenanceTasks();
     $oUtils = oxRegistry::getUtils();
     $sViewID = null;
     if (!$oUtils->isSearchEngine() && !($this->isAdmin() || !$myConfig->getConfigParam('blLogging'))) {
         $this->_log($sClass, $sFunction);
     }
     // starting resource monitor
     $this->_startMonitor();
     // caching params ...
     $sOutput = null;
     $blIsCached = false;
     // Initialize view object and it's components.
     $oViewObject = $this->_initializeViewObject($sClass, $sFunction, $aParams, $aViewsChain);
     if (!$this->_canExecuteFunction($oViewObject, $oViewObject->getFncName())) {
         /** @var oxSystemComponentException $oException */
         $oException = oxNew('oxSystemComponentException', 'Non public method cannot be accessed');
         throw $oException;
     }
     // executing user defined function
     $oViewObject->executeFunction($oViewObject->getFncName());
     // if no cache was stored before we should generate it
     if (!$blIsCached) {
         $sOutput = $this->_render($oViewObject);
     }
     $oOutput = $this->_getOutputManager();
     $oOutput->setCharset($oViewObject->getCharSet());
     if (oxRegistry::getConfig()->getRequestParameter('renderPartial')) {
         $oOutput->setOutputFormat(oxOutput::OUTPUT_FORMAT_JSON);
         $oOutput->output('errors', $this->_getFormattedErrors($oViewObject->getClassName()));
     }
     $oOutput->sendHeaders();
     $oOutput->output('content', $sOutput);
     $myConfig->pageClose();
     stopProfile('process');
     // stopping resource monitor
     $this->_stopMonitor($oViewObject->getIsCallForCache(), $blIsCached, $sViewID, $oViewObject->getViewData());
     // flush output (finalize)
     $oOutput->flushOutput();
 }
コード例 #29
0
 /**
  * Returns manufacturer seo uri for current article
  *
  * @param oxArticle $oArticle     article object
  * @param int       $iLang        language id
  * @param bool      $blRegenerate if TRUE forces seo url regeneration
  *
  * @return string
  */
 public function getArticleManufacturerUri($oArticle, $iLang, $blRegenerate = false)
 {
     $sSeoUri = null;
     startProfile(__FUNCTION__);
     if ($oManufacturer = $this->_getManufacturer($oArticle, $iLang)) {
         //load details link from DB
         if ($blRegenerate || !($sSeoUri = $this->_loadFromDb('oxarticle', $oArticle->getId(), $iLang, null, $oManufacturer->getId(), true))) {
             $oArticle = $this->_getProductForLang($oArticle, $iLang);
             // create title part for uri
             $sTitle = $this->_prepareArticleTitle($oArticle);
             // create uri for all categories
             $sSeoUri = oxRegistry::get("oxSeoEncoderManufacturer")->getManufacturerUri($oManufacturer, $iLang);
             $sSeoUri = $this->_processSeoUrl($sSeoUri . $sTitle, $oArticle->getId(), $iLang);
             $aStdParams = array('mnid' => $oManufacturer->getId(), 'listtype' => $this->_getListType());
             $this->_saveToDb('oxarticle', $oArticle->getId(), oxRegistry::get("oxUtilsUrl")->appendUrl($oArticle->getBaseStdLink($iLang), $aStdParams), $sSeoUri, $iLang, null, 0, $oManufacturer->getId());
         }
         stopProfile(__FUNCTION__);
     }
     return $sSeoUri;
 }
コード例 #30
0
 /**
  * Returns SEO uri for passed category
  *
  * @param oxCategory $oCat         category object
  * @param int        $iLang        language
  * @param bool       $blRegenerate if TRUE forces seo url regeneration
  *
  * @return string
  */
 public function getCategoryUri($oCat, $iLang = null, $blRegenerate = false)
 {
     startProfile(__FUNCTION__);
     $sCatId = $oCat->getId();
     // skipping external category URLs
     if ($oCat->oxcategories__oxextlink->value) {
         $sSeoUrl = null;
     } else {
         // not found in cache, process it from the top
         if (!isset($iLang)) {
             $iLang = $oCat->getLanguage();
         }
         $aCacheMap = array();
         $aStdLinks = array();
         while ($oCat && !($sSeoUrl = $this->_categoryUrlLoader($oCat, $iLang))) {
             if ($iLang != $oCat->getLanguage()) {
                 $sId = $oCat->getId();
                 $oCat = oxNew('oxCategory');
                 $oCat->loadInLang($iLang, $sId);
             }
             // prepare oCat title part
             $sTitle = $this->_prepareTitle($oCat->oxcategories__oxtitle->value, false, $oCat->getLanguage());
             foreach (array_keys($aCacheMap) as $id) {
                 $aCacheMap[$id] = $sTitle . '/' . $aCacheMap[$id];
             }
             $aCacheMap[$oCat->getId()] = $sTitle;
             $aStdLinks[$oCat->getId()] = $oCat->getBaseStdLink($iLang);
             // load parent
             $oCat = $oCat->getParentCategory();
         }
         foreach ($aCacheMap as $sId => $sUri) {
             $this->_aCatCache[$sId . '_' . $iLang] = $this->_processSeoUrl($sSeoUrl . $sUri . '/', $sId, $iLang);
             $this->_saveToDb('oxcategory', $sId, $aStdLinks[$sId], $this->_aCatCache[$sId . '_' . $iLang], $iLang);
         }
         $sSeoUrl = $this->_aCatCache[$sCatId . '_' . $iLang];
     }
     stopProfile(__FUNCTION__);
     return $sSeoUrl;
 }